Title: | Bounded Density Estimation |
---|---|
Description: | A collection of S4 classes which implements different methods to estimate and deal with densities in bounded domains. That is, densities defined within the interval [lower.limit, upper.limit], where lower.limit and upper.limit are values that can be set by the user. |
Authors: | Guzman Santafe, Borja Calvo, Aritz Perez and Jose A. Lozano |
Maintainer: | Guzman Santafe <[email protected]> |
License: | GPL-2 |
Version: | 1.0.1.1 |
Built: | 2024-10-26 06:30:06 UTC |
Source: | CRAN |
Function to access all the methods
bde(dataPoints,dataPointsCache=NULL,estimator,b=length(sample)^{-2/5}, lower.limit=0, upper.limit=1,options=NULL)
bde(dataPoints,dataPointsCache=NULL,estimator,b=length(sample)^{-2/5}, lower.limit=0, upper.limit=1,options=NULL)
dataPoints |
Vector containing the points to be used to estimate the density. |
dataPointsCache |
Points where the density has to be estimated. If omitted, 101 points equally distributed in the [lower.limit,upper.limit] interval are used |
estimator |
Density estimator to be used. This has to be one of the following:
|
b |
Bandwidth to be used. Note that in the case of Vitale's estimator the m parameter is set at |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
options |
A list containing the different options available for the estimators: |
betakernel:
"modified"
: a logical value indicating whether the modified kernel has to be used or not. False by default
"normalization"
: a string: "none"
, to use the original kernels, "densitywise"
to use the macrobeta kernels and "kernelwise"
to use the microbeta kernels. If not specified, no normalization is used
"mbc"
: a string indicating the multiplicative bias correction to be used: "none"
, no correction is used, "jnl"
Hirukawa's JNL approach, "ts"
Hirukawa's TS approach. If not specified, no correction is used
"c"
: a numeric value between 0 and 1 corresponding to the c
parameter in the TS correction (it is only taken into consideration if TS correction is selected). Default value is set to 0.5
vitale:
"biasreduced"
: a logical value. If true, Leblanc's bias reduced estimator is used; otherwise the original estimator is used. False by default
boundarykernel:
"mu"
: numeric parameter to indicate the kind of kernel. Options are 0, for the rectangular function, 1 for Epanechnikov's kernel, 2 for the quadratic and 3 for the biquadratic. Default value is set at 1
"method"
: a string indicating the functions to be used: "Muller94"
(default value), "Muller91"
, "Normalize"
or "None"
"corrected"
: a logical value indicating whether Jones' non-negativity correction should be used. By default it is set to false
kakizawa:
"method"
: a string indicating the function to be used "b1"
, "b2"
or "b3"
(default value).
"estimator"
: a Bounded Density estimator. See all accepted classes here with getSubclasses("BoundedDensity")
. If no estimator is provided, a Muller94BoundaryKernel estimator with default parameters and the same dataPoints as those give for the Kakizawa estimator is used.
"gamma"
: in case that b1
function is used the gamma
parameter is required. This parameter takes 0.5 as default value.
This is a synthetic generated dataset sampling a beta distribution with parameters shape1 = 0.75
and shape2 = 0.65
beta_0.75_0.65
beta_0.75_0.65
A vector containing 10000 observations.
This is a synthetic generated dataset sampling a beta distribution with parameters shape1 = 1
and shape2 = 10
beta_1_10
beta_1_10
A vector containing 10000 observations.
This is a synthetic generated dataset sampling a beta distribution with parameters shape1 = 5
and shape2 = 10
beta_5_10
beta_5_10
A vector containing 10000 observations.
BoundedDensity
generator methodUser friendly constructor method for BoundedDensity
objects.
boundedDensity(x,densities,lower.limit=0,upper.limit=1)
boundedDensity(x,densities,lower.limit=0,upper.limit=1)
x |
a numeric vector containing data samples within the |
densities |
a numeric vector containing the density for each point in |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See BoundedDensity
class for more details.
"BoundedDensity"
This class deals with generic estimations of a bounded densities. The probability density function is approximated by providing a set of data points in a lower and upper bounded interval and their associated densities. Using this information, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function boundedDensity
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
# data points and its densities a <- seq(0,1,0.01) b <- dbeta(a,5,10) # create the density model model <- boundedDensity(x=a,densities=b) # examples of usual functions density(model,0.5) distribution(model,0.2,discreteApproximation=FALSE) distribution(model,0.2,discreteApproximation=TRUE) # graphical representation hist(b,freq=FALSE) lines(model, col="red",lwd=2)
# data points and its densities a <- seq(0,1,0.01) b <- dbeta(a,5,10) # create the density model model <- boundedDensity(x=a,densities=b) # examples of usual functions density(model,0.5) distribution(model,0.2,discreteApproximation=FALSE) distribution(model,0.2,discreteApproximation=TRUE) # graphical representation hist(b,freq=FALSE) lines(model, col="red",lwd=2)
BrVitale
generator methodUser friendly constructor method for BrVitale
objects.
brVitale(dataPoints, m=round(length(dataPoints)^(2/5)), M=NULL, dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
brVitale(dataPoints, m=round(length(dataPoints)^(2/5)), M=NULL, dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
m |
a integer value indicating the order of the polynomial approximation. |
M |
a numeric value indicating the parameter for bias reduction, with |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See BrVitale
class for more details.
"BrVitale"
This class deals with bias reduced version of Vitale (1975) Bernstein Polynomial approximation as described in Leblanc (2009). The polynomial estimator is computed using the provided data samples. Using this polynomial estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function brVitale
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
m
:the order of the polynomial approximation
M
:a numeric parameter for bias reduction. Usually this parameter is set to m/2
since it leads to optimal MISE (mean integrated squared error) properties
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getm"
for details
See "getM"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Vitale, R. A. (1975). A Bernstein polynomial approach to density function estimation. tatistical Inference and Related Topics, 2, 87-99.
Leblanc, A. (2010). A bias-reduced approach to density estimation using Bernstein polynomials. Journal of Nonparametric Statistics, 22(4), 459-475.
# create the model model <- brVitale(dataPoints = tuna.r, m = 25, M = 25/2) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model,show=TRUE,includePoints=TRUE)
# create the model model <- brVitale(dataPoints = tuna.r, m = 25, M = 25/2) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model,show=TRUE,includePoints=TRUE)
chen99Kernel
generator methodUser friendly constructor method for Chen99Kernel
objects.
chen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
chen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See Chen99Kernel
class for more details.
"Chen99Kernel"
This class deals with Kernel estimators for bounded densities as described in Chen's 99 paper. The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function chen99Kernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Chen, S. X. (1999). Beta kernel estimators for density functions. Computational Statistics & Data Analysis, 31, 131-145.
# create the model kernel.noModified <- chen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- chen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("KernelNoModified"=kernel.noModified, "KernelModified"=kernel.Modified),show=TRUE)
# create the model kernel.noModified <- chen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- chen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("KernelNoModified"=kernel.noModified, "KernelModified"=kernel.Modified),show=TRUE)
Density function for the given bounded density object.
x |
A bounded density estimator. See all the accepted classes here by running the command |
values |
Vector of points where the density function is evaluated. These points must be in the interval [ |
density(x,values)
Distribution function for the given bounded density object
.Object |
A bounded density estimator. See all the accepted classes here by running the command |
x |
Vector of points where the density function is evaluated. These points must be in the interval [ |
discreteApproximation |
Logical; if |
If discreteApproximation
is not specified it assumes the default value TRUE
. When the distribution function is used with a BoundedDensity
object, discreteApproximation
value is and a discrete approximation is always obtained.
distribution(.Object,x,discreteApproximation=TRUE)
The dataset comprises lengths (in minutes) of eruptions of Old Faithful geyser in Yellowstone National Park, USA. The data are within the interval [1.67,4.93].
eruption
eruption
A vector containing 107 observations.
The data were obtained from Silverman (1996) Table 2.2
Silverman, B. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall
Weisberg, S. (1980). Applied linear regression. John Wiley & Sons, Canada
b
slotThis method obtains the values stored in the b
slot of a bounded density object. This slot contains the bandwidth parameter for the kernel estimator.
.Object |
A kernel density estimator. See all the accepted classes here by running the command |
getb(.Object)
c
slotThis method obtains the values stored in the c
slot of a HirukawaTSKernel object. This parameter is used in the kernel estimation as a smoothing parameter.
.Object |
A |
getc(.Object)
dataPoints
slotThis method obtains the values stored in the DataPoints
slot of a bounded density object. This slot contains the data sample used to estimate the density model.
.Object |
A bounded density estimator. See all the accepted classes by running the commands |
getdataPoints(.Object)
DataPointsCache
slotThis method obtains the values stored in the dataPointsCache
slot of a bounded density object.
.Object |
A bounded density estimator. See all the accepted classes here by running the command |
getdataPointsCache(.Object)
densityCache
slotThis method obtains the values stored in the DensityCache
slot of a bounded density object
.Object |
A bounded density estimator. See all the accepted classes here by running the command |
getdensityCache(.Object)
gamma
slotThis method obtains the class name of the object stored in the densityEstimator
slot of a KakizawaB1, KakizawaB2 or KakizawaB3 object.
.Object |
A |
getdensityEstimator(.Object)
distributionCache
slotThis method obtains the values stored in the DistributionCache
slot of a bounded density object.
.Object |
A bounded density estimator. See all the accepted classes here by running the command |
getdistributionCache(.Object)
gamma
slotThis method obtains the values stored in the gamma
slot of a KakizawaB1 object. This slot contains a parameter used in the B1 approximation using Bernstein polynomials.
.Object |
A |
getgamma(.Object)
m
slotThis method obtains the values stored in the m
slot of a BernsteinPolynomials object. This slot contains the order of the polynomial expansion.
.Object |
A boundary kernel density estimator. See all the accepted classes here with |
getm(.Object)
M
slotThis method obtains the values stored in the M
slot of a BrVitale object. This slot contains parameter for bias reduction.
.Object |
A |
getM(.Object)
modified
slotThis method obtains the values stored in the modified
slot of a Kernel density object. The value of this slot is TRUE
if a modified version of the kernel estimator is used and FALSE
otherwise.
.Object |
A kernel density estimator. See all the accepted classes here by running the command |
getgetmodified(.Object)
Mu
slotThis method obtains the values stored in the mu
slot of a Boundary Kernel object. This slot contains the degree of smoothing for the boundary kernel estimator. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (bicuadratic kernel) or 3 (tricuadratic kernel).
.Object |
A boundary kernel density estimator. See all the accepted classes here with |
getmu(.Object)
This method returns a list containing the name of the class given as parameter and all the subclasses. Virtual classes are excluded from the list.
getSubclasses(className)
getSubclasses(className)
className |
a string with the name of a S4 class |
# show the names of the class BoundedDensity and all its subclasses getSubclasses("BoundedDensity") # show the names of the class Chen99Kernel and all its subclasses getSubclasses("Chen99Kernel")
# show the names of the class BoundedDensity and all its subclasses getSubclasses("BoundedDensity") # show the names of the class Chen99Kernel and all its subclasses getSubclasses("Chen99Kernel")
Function to plot bounded density probability density functions.
.Object |
A bounded density estimator or a list of bounded density estimators. See all the accepted classes here by running the command |
show |
Logical value. If |
includePoints |
Logical value. It determines whether or not the point used to estimate the density ( |
lwd |
Usual line width graphical parameter. See |
alpha |
A value between 0 and 1 indicating the transparency of the points when they are included in the plot |
gplot(.Object,show=FALSE,includePoints=FALSE,lwd=1,alpha=1)
Wickham, H. (2009). ggplot2: Elegant Graphics for Data Analysis. Springer.
HirukawaJLNKernel
generator methodUser friendly constructor method for HirukawaJLNKernel
objects.
hirukawaJLNKernel(dataPoints, b, dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
hirukawaJLNKernel(dataPoints, b, dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See HirukawaJLNKernel
class for more details.
"HirukawaJLNKernel"
This class deals with the JLN Kernel estimator as described in Hirukawa (2010). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function hirukawaJLNKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Hirukawa, M. (2010). Nonparametric multiplicative bias correction for kernel-type density estimation on the unit interval. Computational Statistics & Data Analysis, 54(2), 473-495.
# create the model kernel.noModified <- hirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- hirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- hirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- hirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
HirukawaTSKernel
generator methodUser friendly constructor method for HirukawaTSKernel
objects.
hirukawaTSKernel(dataPoints, c, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
hirukawaTSKernel(dataPoints, c, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
c |
a numeric value between 0 and 1. This parameter is used in the TS approximation as a smoothing parameter |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See HirukawaTSKernel
class for more details.
"HirukawaTSKernel"
This class deals with the TS Kernel estimator as described in Hirukawa (2010). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function hirukawaTSKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
c
:a numeric value between 0 and 1. This parameter is used in the TS approximation as a smoothing parameter
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
See "getc"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Hirukawa, M. (2010). Nonparametric multiplicative bias correction for kernel-type density estimation on the unit interval. Computational Statistics & Data Analysis, 54(2), 473-495.
# create the model kernel.noModified <- hirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE, c = 0.5) kernel.Modified <- hirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE, c = 0.5) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- hirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE, c = 0.5) kernel.Modified <- hirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE, c = 0.5) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
JonesCorrectionMuller91BoundaryKernel
generator methodUser friendly constructor method for JonesCorrectionMuller91BoundaryKernel
objects.
jonesCorrectionMuller91BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
jonesCorrectionMuller91BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See JonesCorrectionMuller91BoundaryKernel
class for more details.
"JonesCorrectionMuller91BoundaryKernel"
This class deals with nonnegative boundary correction of the muller91BoundaryKernel
estimators for bounded densities. In this normalization, two kernel functions are needed. The first kernel funciton -K(u)
- is the kernel function used in muller91BoundaryKernel
(using left boundary, interior or right boundary kernel functions as needed). For the second kernel function, the popular choice L(u) = u * K(u)
is taken. The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that the renormalization of this kernel estimator guarantees nonnegative values for the density function but the cumulative density function may takes values greater than 1.
Objects can be created by using the generator function jonesCorrectionMuller91BoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
normalizedKernel
:this slot is used to save a NormalizedBoundaryKernel object used in the normalization. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Jones, M. C. and Foster, P. J. (1996). A simple nonnegative boundary correction method for kernel density estimation. Statistica Sinica, 6, 1005-1013.
Muller, H. (1991). Smooth optimum kernel estimators near endpoints. Biometrika, 78(3), 521-530.
# create the model kernel <-jonesCorrectionMuller91BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
# create the model kernel <-jonesCorrectionMuller91BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
JonesCorrectionMuller94BoundaryKernel
generator methodUser friendly constructor method for JonesCorrectionMuller94BoundaryKernel
objects.
jonesCorrectionMuller94BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
jonesCorrectionMuller94BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See JonesCorrectionMuller94BoundaryKernel
class for more details.
"JonesCorrectionMuller94BoundaryKernel"
This class deals with nonnegative boundary correction of the muller94BoundaryKernel
estimators for bounded densities. In this normalization, two kernel functions are needed. The first kernel funciton -K(u)
- is the kernel function used in muller94BoundaryKernel
(using left boundary, interior or right boundary kernel functions as needed). For the second kernel function, the popular choice L(u) = u * K(u)
is taken. The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that the renormalization of this kernel estimator guarantees nonnegative values for the density function but the cumulative density function may takes values greater than 1.
Objects can be created by using the generator function jonesCorrectionMuller94BoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
normalizedKernel
:this slot is used to save a NormalizedBoundaryKernel object used in the normalization. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Jones, M. C. and Foster, P. J. (1996). A simple nonnegative boundary correction method for kernel density estimation. Statistica Sinica, 6, 1005-1013.
Muller, H. and Wang, J. (1994). Hazard rate estimation under random censoring with varying kernels and bandwidths. Biometrics, 50(1), 61-76.
# data points to cache densities and distribution cache <- seq(0,1,0.01) # create the model kernel <-jonesCorrectionMuller94BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2, dataPointsCache = cache) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints = TRUE)
# data points to cache densities and distribution cache <- seq(0,1,0.01) # create the model kernel <-jonesCorrectionMuller94BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2, dataPointsCache = cache) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints = TRUE)
KakizawaB1
generator methodUser friendly constructor method for KakizawaB1
objects.
kakizawaB1(dataPoints,estimator=NULL,m=round(length(dataPoints)^(2/5)),gamma=0.5, dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
kakizawaB1(dataPoints,estimator=NULL,m=round(length(dataPoints)^(2/5)),gamma=0.5, dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
estimator |
A bounded density estimator. See all the accepted classes here with getSubclasses("BoundedDensity"). If no estimator is provided here (default value = NULL), a Muller94BoundaryKernel estimator with default parameters and the same dataPoints as those give for the Kakizawa estimator is used. |
m |
a integer value indicating the order of the polynomial approximation. |
gamma |
a numeric value between 0 and 1. This parameter is used in the B1 approximation using Bernstein polynomials |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See KakizawaB1
class for more details.
"KakizawaB1"
This class deals with B1 approximation to kernel density estimation as described in Kakizawa (2004). This is a Berstein polynomial approximation of the density function which uses BoundedDensity objects instead of a polynomial function. By contrast to the original Kakizawa's approach where only boundary kernels are used, here, any BoundedDensity object is allowed. Using this estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function kakizawaB1
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
gamma
:a numeric value between 0 and 1. This parameter is used in the B1 approximation using Bernstein polynomials
densityEstimator
:a BoundedDensity object used to estimate the density
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getm"
for details
See "getgamma"
for details
See "getdensityEstimator"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Kakizawa, Y. (2004). Bernstein polynomial probability density estimation. Journal of Nonparametric Statistics, 16(5), 709-729.
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB1(dataPoints = tuna.r, m = 25, gamma = 0.25) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB1(dataPoints = tuna.r, m = 25, gamma = 0.25) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
KakizawaB2
generator methodUser friendly constructor method for KakizawaB2
objects.
kakizawaB2(dataPoints, estimator=NULL,m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
kakizawaB2(dataPoints, estimator=NULL,m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
estimator |
A bounded density estimator. See all the accepted classes here with getSubclasses("BoundedDensity"). If no estimator is provided here (default value = NULL), a Muller94BoundaryKernel estimator with default parameters and the same dataPoints as those give for the Kakizawa estimator is used. |
m |
a integer value indicating the order of the polynomial approximation. |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See KakizawaB2
class for more details.
"KakizawaB2"
This class deals with B2 approximation to kernel density estimation as described in Kakizawa (2004). This is a Berstein polynomial approximation of the density function which uses BoundedDensity objects instead of a polynomial function. By contrast to the original Kakizawa's approach where only boundary kernels are used, here, any BoundedDensity object is allowed. Using this estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function kakizawaB2
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
densityEstimator
:a BoundedDensity object used to estimate the density
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getm"
for details
See "getdensityEstimator"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Kakizawa, Y. (2004). Bernstein polynomial probability density estimation. Journal of Nonparametric Statistics, 16(5), 709-729.
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB2(dataPoints = tuna.r, m = 25, estimator = est) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB2(dataPoints = tuna.r, m = 25, estimator = est) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
KakizawaB3
generator methodUser friendly constructor method for KakizawaB3
objects.
kakizawaB3(dataPoints, estimator=NULL,m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
kakizawaB3(dataPoints, estimator=NULL,m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
estimator |
A bounded density estimator. See all the accepted classes here with getSubclasses("BoundedDensity"). If no estimator is provided here (default value = NULL), a Muller94BoundaryKernel estimator with default parameters and the same dataPoints as those give for the Kakizawa estimator is used. |
m |
a integer value indicating the order of the polynomial approximation. |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See KakizawaB3
class for more details.
"KakizawaB3"
This class deals with B3 approximation to kernel density estimation as described in Kakizawa (2004). This is a Berstein polynomial approximation of the density function which uses BoundedDensity objects instead of a polynomial function. By contrast to the original Kakizawa's approach where only boundary kernels are used, here, any BoundedDensity object is allowed. Using this estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function kakizawaB3
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
densityEstimator
:a BoundedDensity object used to estimate the density
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getm"
for details
See "getdensityEstimator"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Kakizawa, Y. (2004). Bernstein polynomial probability density estimation. Journal of Nonparametric Statistics, 16(5), 709-729.
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB3(dataPoints = tuna.r, m = 25, estimator = est) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
# create the model # we use a MicroBetaChen99Kernel is used as estimator y KakizawaB1 approximation est <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) model <- kakizawaB3(dataPoints = tuna.r, m = 25, estimator = est) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
Runs the shiny service for the bde package.
launchApp(...)
launchApp(...)
... |
no parameters are needed |
Function to draw a bounded density probability density functions in the current plot.
x |
A bounded density estimator.See all the accepted classes here by running the command |
... |
Arguments to be passed to methods, such as graphical parameters (see |
lines(x,...)
MacroBetaChen99Kernel
generator methodUser friendly constructor method for MacroBetaChen99Kernel
objects.
macroBetaChen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
macroBetaChen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See MacroBetaChen99Kernel
class for more details.
"MacroBetaChen99Kernel"
This class deals with the density-wise normalization (macro beta) of the Chen's 99 Kernel estimator (as described in Gourierous and Monfort, 2006). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function macroBetaChen99Kernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
normalizationConst
:this slot is used to save the density-wise normalization constant. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Chen, S. X. (1999). Beta kernel estimators for density functions. Computational Statistics & Data Analysis, 31, 131-145.
Gourieroux, C. and Monfort, A. (2006). (Non) consistency of the Beta Kernel Estimator for Recovery Rate Distribution. Working Paper 2006-31, Centre de Recherche en Economie et Statistique.
# create the model kernel.noModified <- macroBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- macroBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- macroBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- macroBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
MacroBetaHirukawaJLNKernel
generator methodUser friendly constructor method for MacroBetaHirukawaJLNKernel
objects.
macroBetaHirukawaJLNKernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
macroBetaHirukawaJLNKernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See MacroBetaHirukawaJLNKernel
class for more details.
"MacroBetaHirukawaJLNKernel"
This class deals with the density-wise normalization (macro beta) of the JLN Kernel estimator as described in Hirukawa (2010). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function macroBetaHirukawaJLNKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
normalizationConst
:this slot is used to save the density-wise normalization constant. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Hirukawa, M. (2010). Nonparametric multiplicative bias correction for kernel-type density estimation on the unit interval. Computational Statistics & Data Analysis, 54(2), 473-495.
# create the model kernel.noModified <- macroBetaHirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- macroBetaHirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- macroBetaHirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- macroBetaHirukawaJLNKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
MacroBetaHirukawaTSKernel
generator methodUser friendly constructor method for MacroBetaHirukawaTSKernel
objects.
macroBetaHirukawaTSKernel(dataPoints, c, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
macroBetaHirukawaTSKernel(dataPoints, c, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
c |
a numeric value between 0 and 1. This parameter is used in the TS approximation as a smoothing parameter |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See MacroBetaHirukawaTSKernel
class for more details.
"MacroBetaHirukawaTSKernel"
This class deals with the density-wise normalization (macro beta) of the TS Kernel estimator as described in Hirukawa (2010). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function macroBetaHirukawaTSKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
c
:a numeric value between 0 and 1. This parameter is used in the TS approximation as a smoothing parameter
normalizationConst
:this slot is used to save the density-wise normalization constant. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Hirukawa, M. (2010). Nonparametric multiplicative bias correction for kernel-type density estimation on the unit interval. Computational Statistics & Data Analysis, 54(2), 473-495.
# create the model kernel.noModified <- macroBetaHirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE, c = 0.5) kernel.Modified <- macroBetaHirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE, c = 0.5) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- macroBetaHirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = FALSE, c = 0.5) kernel.Modified <- macroBetaHirukawaTSKernel(dataPoints = tuna.r, b = 0.01, modified = TRUE, c = 0.5) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified,col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
MicroBetaChen99Kernel
generator methodUser friendly constructor method for MicroBetaChen99Kernel
objects.
microBetaChen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
microBetaChen99Kernel(dataPoints, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, modified = FALSE, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
modified |
if |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See MicroBetaChen99Kernel
class for more details.
"MicroBetaChen99Kernel"
This class deals with the kernel-wise normalization of the Chen's 99 Kernel estimator (as described in Gourierous and Monfort, 2006). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function microBetaChen99Kernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
modified
:if TRUE
, the modified version of the kernel estimator is used
normalizationConstants
:this slot is used to save the kernel-wise normalization constants. It is only for internal use
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmodified"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Chen, S. X. (1999). Beta kernel estimators for density functions. Computational Statistics & Data Analysis, 31, 131-145.
Gourieroux, C. and Monfort, A. (2006). (Non) consistency of the Beta Kernel Estimator for Recovery Rate Distribution. Working Paper 2006-31, Centre de Recherche en Economie et Statistique.
# create the model kernel.noModified <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
# create the model kernel.noModified <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = FALSE) kernel.Modified <- microBetaChen99Kernel(dataPoints = tuna.r, b = 0.01, modified = TRUE) # examples of usual functions density(kernel.noModified,0.5) density(kernel.Modified,0.5) distribution(kernel.noModified,1,discreteApproximation=FALSE) distribution(kernel.noModified,1,discreteApproximation=TRUE) distribution(kernel.Modified,1,discreteApproximation=FALSE) distribution(kernel.Modified,1,discreteApproximation=TRUE) # graphical representation hist(tuna.r,freq=FALSE,main="Chen99 Kernels Tuna Data") lines(kernel.noModified, col="red",lwd=2) lines(kernel.Modified,col="blue",lwd=2) # graphical representation using ggplot2 graph <- gplot(list("noModified"=kernel.noModified, "modified"=kernel.Modified), show=TRUE)
Computes the mean integrated squared error (MISE) for two given Bounded density objects.
mise(model1,model2,discreteApproximation = TRUE)
mise(model1,model2,discreteApproximation = TRUE)
model1 |
a bounded density object. See |
model2 |
a bounded density object. See |
discreteApproximation |
If |
# a general approximation to a Beta(1,10) distribution using BoundedDensity objects cache <- seq(0,1,0.01) dens <- dbeta(cache,1,10) bd <- boundedDensity(x=cache,densities=dens) # a BrVitale approximation to the Beta(1,10) distribution using a random data sample to # learn the model dataSample <- rbeta(100,1,10) kernel <- hirukawaTSKernel(dataPoints=dataSample, b=0.1, c=0.3, dataPointsCache=cache, modified=FALSE) # compute the mise mise(bd,kernel,discreteApproximation=TRUE) mise(bd,kernel,discreteApproximation=FALSE)
# a general approximation to a Beta(1,10) distribution using BoundedDensity objects cache <- seq(0,1,0.01) dens <- dbeta(cache,1,10) bd <- boundedDensity(x=cache,densities=dens) # a BrVitale approximation to the Beta(1,10) distribution using a random data sample to # learn the model dataSample <- rbeta(100,1,10) kernel <- hirukawaTSKernel(dataPoints=dataSample, b=0.1, c=0.3, dataPointsCache=cache, modified=FALSE) # compute the mise mise(bd,kernel,discreteApproximation=TRUE) mise(bd,kernel,discreteApproximation=FALSE)
Muller91BoundaryKernel
generator methodUser friendly constructor method for Muller91BoundaryKernel
objects.
muller91BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
muller91BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See Muller91BoundaryKernel
class for more details.
"Muller91BoundaryKernel"
This class deals with Kernel estimators for bounded densities using boundary kernel described in Muller (1991). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that this kernel estimator is not normalized and therefore it is not a probability distribution (the cumulative density function may return values greater than 1).
Objects can be created by using the generator function muller91BoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Muller, H. (1991). Smooth optimum kernel estimators near endpoints. Biometrika, 78(3), 521-530.
# create the model kernel <- muller91BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
# create the model kernel <- muller91BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
Muller94BoundaryKernel
generator methodUser friendly constructor method for Muller94BoundaryKernel
objects.
muller94BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
muller94BoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See Muller94BoundaryKernel
class for more details.
"Muller94BoundaryKernel"
This class deals with Kernel estimators for bounded densities using boundary kernel described in Muller and Wang (1994). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that this kernel estimator is not normalized and therefore it is not a probability distribution (the cumulative density function may return values greater than 1).
Objects can be created by using the generator function muller94BoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Muller, H. and Wang, J. (1994). Hazard rate estimation under random censoring with varying kernels and bandwidths. Biometrics, 50(1), 61-76.
# create the model kernel <- muller94BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
# create the model kernel <- muller94BoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
NoBoundaryKernel
generator methodUser friendly constructor method for NoBoundaryKernel
objects.
noBoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
noBoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See NoBoundaryKernel
class for more details.
"NoBoundaryKernel"
This class deals with Kernel estimators for bounded densities using boundary kernels where the same kernel function is used for all regions: left boundary, interior and right boundary. The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that this kernel estimator is not normalized and therefore it is not a probability distribution (the cumulative density function may return values greater than 1).
Objects can be created by using the generator function noBoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
# create the model kernel <- noBoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
# create the model kernel <- noBoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
NormalizedBoundaryKernel
generator methodUser friendly constructor method for NormalizedBoundaryKernel
objects.
normalizedBoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
normalizedBoundaryKernel(dataPoints, mu=1, b=length(dataPoints)^(-2/5), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
mu |
a integer value indicating the degree of smoothness for the boundary kernel. |
b |
the bandwidth of the kernel estimator |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See NormalizedBoundaryKernel
class for more details.
"NormalizedBoundaryKernel"
This class deals with Kernel estimators for bounded densities using renormalized boundary kernel described in Kakizawa (2004). The kernel estimator is computed using the provided data samples. Using this kernel estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations. Note that, the renormalization of this kernel guarantees non-negative density values. However, despite its name, the normalized boundary kernel is not a probability distribution (the cumulative density function may return values greater than 1).
Objects can be created by using the generator function normalizedBoundaryKernel
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
b
:the bandwidth of the kernel estimator
mu
:a integer value indicating the degree of smoothness for the boundary kernel. mu
can take the following values: 0 (uniform kernel), 1 (Epanechnikov kernel), 2 (biweight kernel) or 3 (triweight kernel)
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getb"
for details
See "getmu"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Kakizawa, Y. (2004). Bernstein polynomial probability density estimation. Journal of Nonparametric Statistics, 16(5), 709-729.
# create the model kernel <- normalizedBoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel,col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
# create the model kernel <- normalizedBoundaryKernel(dataPoints = tuna.r, b = 0.01, mu = 2) # examples of usual functions density(kernel,0.5) distribution(kernel,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(kernel,col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(kernel, show=TRUE, includePoints=TRUE)
Function to plot bounded density probability density functions.
x |
A bounded density estimator. See all the accepted classes here by running the command |
main , type , xlab , ylab
|
Graphical parameters with default values (see |
... |
Arguments to be passed to methods, such as (other) graphical parameters (see |
plot(x,main="Bounded density",type="l",xlab="X",ylab="Density",...)
Quantile function for the given bounded density object.
x |
A bounded density estimator. See all the accepted classes here by running the command |
p |
Vector of probabilities |
quantile(x,p)
Random generator function for the given bounded density object.
.Object |
A bounded density estimator. See all the accepted classes here by running the command |
n |
number of random observations to be generated |
rsample(.Object,n)
The dataset comprises lengths (in days) of psychiatric treatment spells for patients used as controls in a study of suicide risks. The data have been scaled to the interval [0,1] by dividing each data sample by the maximum value.
suicide.r
suicide.r
A vector containing 86 observations.
The data were obtained from Silverman (1996) Table 2.1
Silverman, B. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall
Copas, J. B. and Fryer, M. J. (1980). Density estimation and suicide risks in psychiatric treatment. Journal of the Royal Statistical Society. Series A, 143(2), 167-176
This is a synthetic generated dataset sampling a truncated Gaussian distribution on the interval [0,1] with mean=0
and sd=0.25
tgaussian
tgaussian
A vector containing 10000 observations.
tuna
dataThe tuna
data come from an aerial line transect survey of Southern Bluefin Tuna in the Great Australian Bight and it is included in the boot
package. The tuna.r
data is a scaled version of the tuna
data within the [0,1] interval. This new data set is obtained as follows:
library(boot)
tuna.r <- tuna$y/17
tuna.r
tuna.r
A vector containing 64 observations.
The data were obtained from
Chen, S.X. (1996). Empirical likelihood confidence intervals for nonparametric density estimation. Biometrica, 83, 329-341.
Vitale
generator methodUser friendly constructor method for Vitale
objects.
vitale(dataPoints, m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
vitale(dataPoints, m=round(length(dataPoints)^(2/5)), dataPointsCache=NULL, lower.limit = 0, upper.limit = 1)
dataPoints |
a numeric vector containing data samples within the |
m |
a integer value indicating the order of the polynomial approximation. |
dataPointsCache |
a numeric vector containing points within the |
lower.limit |
a numeric value for the lower limit of the bounded interval for the data |
upper.limit |
a numeric value for the upper limit of the bounded interval for the data. That is, the data is with the |
See Vitale
class for more details.
"Vitale"
This class deals with Vitale (1975) Bernstein Polynomial approximation as described in Leblanc (2009). The polynomial estimator is computed using the provided data samples. Using this polynomial estimator, the methods implemented in the class can be used to compute densities, values of the distribution function, quantiles, sample the distribution and obtain graphical representations.
Objects can be created by using the generator function vitale
.
dataPointsCache
:a numeric vector containing points within the [lower.limit,upper.limit]
interval
densityCache
:a numeric vector containing the density for each point in dataPointsCache
distributionCache
:a numeric vector used to cache the values of the distribution function. This slot is included to improve the performance of the methods when multiple calculations of the distribution function are used
dataPoints
:a numeric vector containing data samples within the [lower.limit,upper.limit]
interval. These data samples are used to obtain the kernel estimator
m
:the order of the polynomial approximation
lower.limit
:a numeric value for the lower limit of the bounded interval for the data
upper.limit
:a numeric value for the upper limit of the bounded interval for the data
See "density"
for details
See "distribution"
for details
See "quantile"
for details
See "rsample"
for details
See "plot"
for details
See "getdataPointsCache"
for details
See "getdensityCache"
for details
See "getdistributionCache"
for details
See "getdataPoints"
for details
See "getm"
for details
Guzman Santafe, Borja Calvo and Aritz Perez
Vitale, R. A. (1975). A Bernstein polynomial approach to density function estimation. Statistical Inference and Related Topics, 2, 87-99.
Leblanc, A. (2010). A bias-reduced approach to density estimation using Bernstein polynomials. Journal of Nonparametric Statistics, 22(4), 459-475.
# create the model model <- vitale(dataPoints = tuna.r, m = 25) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)
# create the model model <- vitale(dataPoints = tuna.r, m = 25) # examples of usual functions density(model,0.5) distribution(model,0.5,discreteApproximation=FALSE) # graphical representation hist(tuna.r,freq=FALSE,main="Tuna Data") lines(model, col="red",lwd=2) # graphical representation using ggplot2 graph <- gplot(model, show=TRUE, includePoints=TRUE)