Learn R Programming

sm (version 2.0-2)

cv: Cross-validation criterion for nonparametric density estimation

Description

This function computes a cross-validatory criterion, based on integrated squared error, for use in selecting a smoothing parameter in nonparametric density estimation.

Usage

cv(x, h, ...)

Arguments

x
vector, or two-column matrix, of data.
h
a smoothing parameter. In the two-dimensional case this is multiplied by the standard deviation of each component to produce two smoothing parameters
...
other optional parameters are passed to the sm.options function, through a mechanism which limits their effect only to this call of the function; those relevant for this function are the following:
h.weights
a vector of weights which multiply the smoothing parameter(s) used in the kernel function at each observation.

Value

  • The value of the cross-validatory criterion.

Details

See Section 2.4.3 of the reference below. The function is called automatically by hcv and does not usually need to be called independently.

References

Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.

See Also

hcv, hsj, hnorm, sj

Examples

Run this code
x      <- rnorm(50)
hgrid  <- seq(0.1, 1, length = 10)
cvgrid <- vector("numeric", length = length(hgrid))
for (i in 1:10) cvgrid[i] <- cv(x, hgrid[i])
plot(hgrid, cvgrid, type="l")

Run the code above in your browser using DataLab