Learn R Programming

SpatialExtremes (version 2.0-7)

gcv: Estimates the penalty coefficient from the generalized cross-validation criterion

Description

Estimates the penalty coefficient from the generalized cross-validation criterion.

Usage

gcv(y, x, knots, degree, plot = TRUE, n.points = 150, …)

Arguments

y

The response vector.

x

A vector/matrix giving the values of the predictor variable(s). If x is a matrix, each row corresponds to one observation.

knots

A vector givint the coordinates of the knots.

degree

The degree of the penalized smoothing spline.

plot

Logical. If TRUE (default), the evolution of the CV score as the penalty increases is plotted.

n.points

A numeric giving the number of CV computations needed to produce the plot.

Options to be passed to the nlm function.

Value

A list with components 'penalty', 'gcv' and 'nlm.code' which give the location of the minimum, the value of the cross-validation criterion at that point and the code returned by the link{nlm} function - useful to assess for convergence issues.

Details

For every linear smoother e.g. \(\hat{y} = S_\lambda y\), the cross-validation criterion consists in minimizing the following quantity:

$$GCV(\lambda) = \frac{n ||y - \hat{y}||^2}{(n - tr(S_\lambda))^2}$$ where \(\lambda\) is the penalty coefficient, \(n\) the number of observations and \(tr(S_\lambda)\) is the trace of the matrix \(S_\lambda\).

References

Ruppert, D. Wand, M.P. and Carrol, R.J. (2003) Semiparametric Regression Cambridge Series in Statistical and Probabilistic Mathematics.

See Also

cv

Examples

Run this code
# NOT RUN {
n <- 200
x <- runif(n)
fun <- function(x) sin(3 * pi * x)
y <- fun(x) + rnorm(n, 0, sqrt(0.4))
knots <- quantile(x, prob = 1:(n/4) / (n/4 + 1))
gcv(y, x, knots = knots, degree = 3)
# }

Run the code above in your browser using DataLab