Learn R Programming

sROC (version 0.1-2)

kCDF: Kernel Estimation for Cumulative Distribution Function

Description

To compute the nonparametric kernel estimate for cumulative distribution function (CDF).

Usage

kCDF(x, bw="pi_ucv", adjust=1, kernel=c("normal", "epanechnikov"), xgrid, ngrid=256, from, to, cut=3, na.rm = FALSE, ...)

Arguments

x
the data from which the estimate is to be computed.
bw
the smoothing bandwidth to be used. bw can also be a character string giving a rule to choose the bandwidth. See bw.CDF and bw.CDF.pi. The default used the Altman and Leger's plug-in approach with an unbiased cross-validation pilot bandwidth.
adjust
the parameter for adjusting the bandwidth. The bandwidth used for the estimate is actually adjust*bw. By default, $adjust=1$.
kernel
a character string giving the smoothing kernel to be used. This must be either ``normal'' or ``epanechnikov''. By default, the normal kernel is used.
xgrid
the user-defined data points at which the CDF is to be evaluated. If missing, the CDF will be evaluated at the equally spaced points defined within the function.
ngrid
the number of equally spaced points at which the density is to be estimated.
from
the left-most points of the grid at which the density is to be estimated.
to
the right-most points of the grid at which the density is to be estimated
cut
by default, the values of from and to are cut bandwidths beyond the extremes of the data.
na.rm
logical; if TRUE, missing values are removed from x. If FALSE any missing values cause an error.
...
further arguments for methods.

Value

An object of class ``CDF''.
x
the points where the CDF is estimated.
Fhat
the estimated CDF values. These will be numerical numbers between zero and one.
bw
the bandwidth used.
n
the sample size after elimination of missing values.
call
the call which produced the result.
data
the original data after elimination of missing values.
data.name
the deparsed name of the x argument.
has.na
logical; if TRUE, there are missing values in the original data.
The print method reports summary values on the x and Fhat components.

Details

estimate the nonparametric kernel cumulative distribution function.

References

Nadaraya, E.A. (1964). Some new estimators for distribution functions. Theory of Probability and its Applications, 9, 497-500.

Altman, N., and Leger, C. (1995). Bandwidth selection for kernel distribution function estimation. Journal of Statistical Planning and Inference, 46, 195-214.

See Also

bw.CDF, bw.CDF.pi.

Examples

Run this code

## --------------------
set.seed(100)
n <- 200
x <- c(rnorm(n/2, mean=-2, sd=1), rnorm(n/2, mean=3, sd=0.8))
x.CDF <- kCDF(x)
x.CDF
plot(x.CDF, alpha=0.05, main="Kernel estimate of distribution function", CI=FALSE)
curve(pnorm(x, mean=-2, sd=1)/2 + pnorm(x, mean=3, sd=0.8)/2, from =-6, to=6, add=TRUE, lty=2, col="blue")

Run the code above in your browser using DataLab