Skip to content

Commit

Permalink
feat: density, hcdf, quantile, cor, median and IQR functions added
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeJaredS committed May 7, 2023
1 parent 0579fe7 commit 4634f65
Show file tree
Hide file tree
Showing 42 changed files with 2,135 additions and 131 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^cran-comments\.md$
^data-raw$
^CRAN-RELEASE$
^CRAN-SUBMISSION$
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: hermiter
Title: Efficient Sequential and Batch Estimation of Univariate and Bivariate Probability Density Functions and Cumulative Distribution Functions along with Quantiles (Univariate) and Nonparametric Correlation (Bivariate)
Version: 2.2.0
Date: 2022-11-12
Version: 2.3.0
Date: 2023-05-07
Authors@R: c(
person("Michael","Stephanou",role=c("aut","cre"), email="[email protected]"),
person("Melvin","Varughese",role="ctb"))
Expand All @@ -17,7 +17,7 @@ Description: Facilitates estimation of full univariate and bivariate
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>,
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>.
License: MIT + file LICENSE
Depends: R (>= 3.5.0)
Depends: R (>= 3.6.0)
Imports:
Rcpp (>= 1.0.5),
methods,
Expand All @@ -27,7 +27,7 @@ LinkingTo:
BH,
RcppParallel
SystemRequirements: GNU make
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
Suggests:
testthat,
magrittr,
Expand All @@ -38,7 +38,8 @@ Suggests:
ggplot2,
DT,
mvtnorm,
patchwork
patchwork,
colorspace
VignetteBuilder: knitr
ByteCompile: true
URL: https://github.com/MikeJaredS/hermiter
Expand Down
28 changes: 27 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
useDynLib("hermiter", .registration=TRUE)
importFrom(Rcpp, evalCpp)
importFrom(RcppParallel, RcppParallelLibs)
importFrom(stats,quantile)
importFrom(stats,density)
importFrom(stats,median)
importFrom("grDevices", "hcl.colors")
importFrom("graphics", "abline", "filled.contour", "plot.default")
importFrom("methods", "is")
S3method(merge_hermite,list)
S3method(merge_pair,hermite_estimator_univar)
S3method(cum_prob,hermite_estimator_univar)
S3method(hcdf,hermite_estimator_univar)
S3method(dens,hermite_estimator_univar)
S3method(density,hermite_estimator_univar)
S3method(quant,hermite_estimator_univar)
S3method(quantile,hermite_estimator_univar)
S3method(median,hermite_estimator_univar)
S3method(IQR,hermite_estimator_univar)
S3method(IQR,default)
S3method(quant,hermite_estimator_bivar)
S3method(calculate_running_std,hermite_estimator_univar)
S3method(calculate_running_std,hermite_estimator_bivar)
Expand All @@ -16,26 +27,41 @@ S3method(kendall,hermite_estimator_bivar)
S3method(spearmans,hermite_estimator_univar)
S3method(kendall,hermite_estimator_univar)
S3method(cum_prob,hermite_estimator_bivar)
S3method(hcdf,hermite_estimator_bivar)
S3method(dens,hermite_estimator_bivar)
S3method(density,hermite_estimator_bivar)
S3method(update_sequential,hermite_estimator_bivar)
S3method(merge_pair,hermite_estimator_bivar)
S3method(summary,hermite_estimator_univar)
S3method(print,hermite_estimator_univar)
S3method(summary,hermite_estimator_bivar)
S3method(print,hermite_estimator_bivar)
S3method(print,hcdf_univar)
S3method(plot,hcdf_univar)
S3method(summary,hcdf_univar)
S3method(print,hcdf_bivar)
S3method(plot,hcdf_bivar)
S3method(summary,hcdf_bivar)
S3method(print,hdensity_univar)
S3method(plot,hdensity_univar)
S3method(print,hdensity_bivar)
S3method(plot,hdensity_bivar)
export(hermite_estimator)
export(update_sequential)
export(merge_hermite)
export(merge_pair)
export(cum_prob)
export(hcdf)
export(dens)
export(quant)
export(spearmans)
export(kendall)
export(cor)
export(hermite_normalization_N)
export(hermite_function_N)
export(hermite_function_sum_N)
export(hermite_polynomial_N)
export(hermite_int_lower)
export(hermite_int_upper)
export(hermite_int_full)
export(hermite_int_full)
export(IQR)
21 changes: 21 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# hermiter v2.3.0

## Additions and improvements

* Enhanced the update_sequential method to incorporate a single or multiple
new observations.
* Added density generic function which outputs an object with associated print
and plot generics.
* Added quantile generic function for convenience.
* Added hcdf function which outputs an object with associated print,
plot and summary generics.
* Added median and IQR convenience functions.
* Added a wrapper around the stats::cor function with two new methods, namely
"hermite.spearman" and "hermite.kendall".

## Minor improvements and bug fixes

* Additional test cases have been added.
* Updated the vignette.
* Fixed the SystemRequirements: C++11 note.

# hermiter v2.2.0

## Breaking changes
Expand Down
32 changes: 29 additions & 3 deletions R/hermite_estimator.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ merge_hermite.list <- function(hermite_estimators){
#'
#' @param h_est_obj A hermite_estimator_univar or hermite_estimator_bivar
#' object.
#' @param x A numeric value or vector. An observation to be incorporated into
#' the estimator. Note that for univariate estimators, x is a numeric value
#' whereas for bivariate estimators, x is a numeric vector of length 2.
#' @param x A numeric vector or matrix. Observations to be incorporated into
#' the estimator. Note that for univariate estimators, x is a numeric vector
#' whereas for bivariate estimators, x is a numeric vector of length 2 or a
#' n x 2 matrix with n bivariate observations to be incorporated into the
#' estimator.
#' @return An object of class hermite_estimator_univar or
#' hermite_estimator_bivar.
#' @export
Expand Down Expand Up @@ -282,6 +284,30 @@ cum_prob <- function(h_est_obj, x, clipped, accelerate_series = TRUE) {
UseMethod("cum_prob", h_est_obj)
}

#' Creates an object summarizing the CDF with associated generic methods print,
#' plot and summary.
#'
#' The h_est_obj object must be updated with observations prior to the use of
#' the method.
#'
#' @param h_est_obj A hermite_estimator_univar or hermite_estimator_bivar
#' object.
#' @param clipped A boolean value. This value determines whether
#' cumulative probabilities are clipped to lie between 0 and 1.
#' @param accelerate_series A boolean value. This value determines whether
#' Hermite series acceleration is applied.
#' @param x_lower A numeric value (univariate) or a numeric vector (bivariate).
#' This value determines the lower limit of x values at which to evaluate
#' the CDF.
#' @param x_upper A numeric value (univariate) or a numeric vector (bivariate).
#' This value determines the upper limit of x values at which to evaluate
#' the CDF.
#' @return A hcdf_univar or hcdf_bivar object.
hcdf <- function(h_est_obj, clipped = FALSE, accelerate_series = TRUE,
x_lower = NA, x_upper = NA) {
UseMethod("hcdf", h_est_obj)
}

#' Estimates the quantiles at a vector of probability values
#'
#' This method utilizes the estimator (13) in paper Stephanou, Michael,
Expand Down
Loading

0 comments on commit 4634f65

Please sign in to comment.