Skip to content

Commit b26d348

Browse files
authored
Merge pull request #4 from MikeJaredS/performance_enhancements_quantile
Performance enhancements quantile
2 parents 9e57409 + 088aa85 commit b26d348

36 files changed

+1324
-398
lines changed

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: hermiter
22
Title: Efficient Sequential and Batch Estimation of Univariate and Bivariate Probability Density Functions and Cumulative Distribution Functions along with Quantiles (Univariate) and Spearman's Correlation (Bivariate)
3-
Version: 2.0.3
3+
Version: 2.1.0
44
Authors@R: c(
55
person("Michael","Stephanou",role=c("aut","cre"), email="[email protected]"),
66
person("Melvin","Varughese",role="ctb"))
@@ -9,12 +9,12 @@ Author: Michael Stephanou [aut, cre],
99
Maintainer: Michael Stephanou <[email protected]>
1010
Description: Facilitates estimation of full univariate and bivariate
1111
probability density functions and cumulative distribution functions along with
12-
full quantile functions (univariate) and Spearman's rank correlation
12+
full quantile functions (univariate) and nonparametric correlation
1313
(bivariate) using Hermite series based estimators. These estimators are
1414
particularly useful in the sequential setting (both stationary and
1515
non-stationary) and one-pass batch estimation setting for large data sets.
1616
Based on: Stephanou, Michael, Varughese, Melvin and Macdonald, Iain. "Sequential quantiles via Hermite series density estimation." Electronic Journal of Statistics 11.1 (2017): 570-607 <doi:10.1214/17-EJS1245>,
17-
Stephanou, Michael and Varughese, Melvin. "On the properties of Hermite series based distribution function estimators." Metrika (2020) <doi:10.1007/s00184-020-00785-z> and Stephanou, Michael and Varughese, Melvin. "Sequential Estimation of Nonparametric Correlation using Hermite Series Estimators." arXiv Preprint (2020) <arXiv:2012.06287>.
17+
Stephanou, Michael and Varughese, Melvin. "On the properties of Hermite series based distribution function estimators." Metrika (2020) <doi:10.1007/s00184-020-00785-z> and Stephanou, Michael and Varughese, Melvin. "Sequential estimation of Spearman rank correlation using Hermite series estimators." Journal of Multivariate Analysis (2021) <doi:10.1016/j.jmva.2021.104783>.
1818
License: MIT + file LICENSE
1919
Depends: R (>= 3.5.0)
2020
Imports:
@@ -23,7 +23,7 @@ Imports:
2323
LinkingTo:
2424
Rcpp,
2525
BH
26-
RoxygenNote: 7.1.1
26+
RoxygenNote: 7.1.2
2727
Suggests:
2828
testthat,
2929
magrittr,

NAMESPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,26 @@ S3method(calculate_running_std,hermite_estimator_bivar)
1212
S3method(update_batch,hermite_estimator_univar)
1313
S3method(update_sequential,hermite_estimator_univar)
1414
S3method(spearmans,hermite_estimator_bivar)
15+
S3method(kendall,hermite_estimator_bivar)
1516
S3method(spearmans,hermite_estimator_univar)
17+
S3method(kendall,hermite_estimator_univar)
1618
S3method(cum_prob,hermite_estimator_bivar)
1719
S3method(dens,hermite_estimator_bivar)
1820
S3method(update_batch,hermite_estimator_bivar)
1921
S3method(update_sequential,hermite_estimator_bivar)
2022
S3method(merge_pair,hermite_estimator_bivar)
23+
S3method(summary,hermite_estimator_univar)
24+
S3method(print,hermite_estimator_univar)
25+
S3method(summary,hermite_estimator_bivar)
26+
S3method(print,hermite_estimator_bivar)
2127
export(merge_hermite)
2228
export(merge_hermite_univar)
2329
export(merge_hermite_bivar)
2430
export(merge_pair)
2531
export(cum_prob)
2632
export(dens)
2733
export(spearmans)
34+
export(kendall)
2835
export(hermite_estimator)
2936
export(hermite_estimator_univar)
3037
export(hermite_estimator_bivar)
@@ -34,6 +41,7 @@ export(hermite_function_sum)
3441
export(hermite_integral_val)
3542
export(hermite_integral_val_upper)
3643
export(hermite_normalization)
44+
export(hermite_normalization_N)
3745
export(quant)
3846
export(standardizeInputs)
3947
export(standardizeInputsEW)

NEWS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# hermiter v2.1.0
2+
3+
## New features
4+
5+
* A method has been added for estimating the Kendall rank correlation
6+
coefficient in the bivariate setting.
7+
* The univariate quantile estimation method has been significantly enhanced in
8+
accuracy using series acceleration techniques. Series acceleration is enabled
9+
by default.
10+
* The univariate pdf and cdf methods have been significantly enhanced in
11+
accuracy using series acceleration techniques. Series acceleration is enabled
12+
by default.
13+
* The new default method for the univariate quantile estimation method,
14+
'interpolate' is much faster than the alternate method, 'bisection' with nearly
15+
the same accuracy.
16+
* Added print and summary methods for both the univariate and bivariate
17+
hermite_estimator objects.
18+
* Convenience function added to calculate sums of Hermite functions.
19+
20+
## Documentation improvements
21+
22+
* The vignette `hermiter`, namely `vignette("hermiter")` has been extended to
23+
included examples pertaining to estimation of the Kendall Tau nonparametric
24+
correlation coefficient in the bivariate setting.
25+
126
# hermiter v2.0.3
227

328
## Minor improvements and bug fixes

R/hermite_estimator.R

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
#' hermite_estimator_bivar.
2626
#' @export
2727
#' @examples
28-
#' hermite_est <- hermite_estimator(N = 10, standardize = TRUE,
28+
#' hermite_est <- hermite_estimator(N = 30, standardize = TRUE,
2929
#' est_type="univariate")
3030
hermite_estimator <-
31-
function(N = 10,
32-
standardize = FALSE,
31+
function(N = 30,
32+
standardize = TRUE,
3333
exp_weight_lambda = NA, est_type = "univariate") {
3434
if (!is.numeric(N)) {
3535
stop("N must be numeric.")
@@ -204,6 +204,8 @@ calculate_running_std <- function(this)
204204
#' values at which to calculate the probability density.
205205
#' @param clipped A boolean value. This value determines whether
206206
#' probability densities are clipped to be bigger than zero.
207+
#' @param accelerate_series A boolean value. This value determines whether
208+
#' Hermite series acceleration is applied.
207209
#' @return A numeric vector of probability density values.
208210
#' @export
209211
#' @examples
@@ -217,7 +219,7 @@ calculate_running_std <- function(this)
217219
#' nrow=30, ncol=2,byrow=TRUE))
218220
#' pdf_est <- dens(hermite_est, matrix(c(0,0,0.5,0.5,1,1),nrow=3,
219221
#' ncol=2,byrow=TRUE))
220-
dens <- function(this, x, clipped) {
222+
dens <- function(this, x, clipped, accelerate_series = TRUE) {
221223
UseMethod("dens", this)
222224
}
223225

@@ -235,6 +237,8 @@ dens <- function(this, x, clipped) {
235237
#' Values at which to calculate the cumulative probability.
236238
#' @param clipped A boolean value. This value determines whether
237239
#' cumulative probabilities are clipped to lie between 0 and 1.
240+
#' @param accelerate_series A boolean value. This value determines whether
241+
#' Hermite series acceleration is applied.
238242
#' @return A numeric vector of cumulative probability values.
239243
#' @export
240244
#' @examples
@@ -248,7 +252,7 @@ dens <- function(this, x, clipped) {
248252
#' nrow=30, ncol=2,byrow=TRUE))
249253
#' cdf_est <- cum_prob(hermite_est, matrix(c(0,0,0.5,0.5,1,1),nrow=3,
250254
#' ncol=2,byrow=TRUE))
251-
cum_prob <- function(this, x, clipped) {
255+
cum_prob <- function(this, x, clipped, accelerate_series = TRUE) {
252256
UseMethod("cum_prob", this)
253257
}
254258

@@ -263,6 +267,16 @@ cum_prob <- function(this, x, clipped) {
263267
#'
264268
#' @param this A hermite_estimator_univar object.
265269
#' @param p A numeric vector. A vector of probability values.
270+
#' @param algorithm A string. Two possible values 'interpolate' which is faster
271+
#' but may be less accurate or 'bisection' which is slower but potentially more
272+
#' accurate.
273+
#' @param accelerate_series A boolean value. If set to TRUE, the series
274+
#' acceleration methods described in:
275+
#'
276+
#' Boyd, John P., and Dennis W. Moore. "Summability methods for
277+
#' Hermite functions." Dynamics of atmospheres and oceans 10.1 (1986): 51-62.
278+
#'
279+
#' are applied. If set to FALSE, then standard summation is applied.
266280
#' @return A numeric vector. The vector of quantile values associated with the
267281
#' probabilities p.
268282
#' @export
@@ -271,7 +285,7 @@ cum_prob <- function(this, x, clipped) {
271285
#' est_type="univariate")
272286
#' hermite_est <- update_batch(hermite_est, rnorm(30))
273287
#' quant_est <- quant(hermite_est, c(0.25, 0.5, 0.75))
274-
quant <- function(this, p) {
288+
quant <- function(this, p, algorithm="interpolate", accelerate_series = TRUE) {
275289
UseMethod("quant", this)
276290
}
277291

@@ -298,3 +312,45 @@ spearmans <- function(this, clipped = FALSE)
298312
{
299313
UseMethod("spearmans",this)
300314
}
315+
316+
#' Estimates the Kendall rank correlation coefficient
317+
#'
318+
#' This method calculates the Kendall rank correlation coefficient value. It
319+
#' is only applicable to the bivariate Hermite estimator i.e. est_type =
320+
#' "bivariate".
321+
#'
322+
#' The object must be updated with observations prior to the use of this method.
323+
#'
324+
#' @param this A hermite_estimator_bivar object.
325+
#' @param clipped A boolean value. Indicates whether to clip the Kendall rank
326+
#' correlation estimates to lie between -1 and 1.
327+
#' @return A numeric value.
328+
#' @export
329+
#' @examples
330+
#' hermite_est <- hermite_estimator(N = 10, standardize = TRUE,
331+
#' est_type="bivariate")
332+
#' hermite_est <- update_batch(hermite_est, matrix(rnorm(30*2), nrow=30,
333+
#' ncol=2, byrow = TRUE))
334+
#' kendall_est <- kendall(hermite_est)
335+
kendall <- function(this, clipped = FALSE)
336+
{
337+
UseMethod("kendall",this)
338+
}
339+
340+
# Internal helper function for print methods.
341+
describe_estimator <- function(this, est_type){
342+
if (est_type == "univariate") {
343+
cat("Univariate Hermite Estimator:\n")
344+
} else {
345+
cat("Bivariate Hermite Estimator:\n")
346+
}
347+
cat(paste0("N = ",this$N_param,"\n"))
348+
cat(paste0("Standardize observations = ",this$standardize_obs,"\n"))
349+
if (!is.na(this$exp_weight)){
350+
cat(paste0("Exponential weighting for coefficents = TRUE, lambda = ",
351+
this$exp_weight,"\n"))
352+
} else {
353+
cat(paste0("Exponential weighting for coefficents = FALSE","\n"))
354+
}
355+
cat(paste0("Number of observations = ",this$num_obs,"\n"))
356+
}

0 commit comments

Comments
 (0)