Learn R Programming

SpatialExtremes (version 2.0-7)

rbpspline: Fits a penalized spline with radial basis functions to data

Description

Fits a penalized spline with radial basis functions to data.

Usage

rbpspline(y, x, knots, degree, penalty = "gcv", …)

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.

penalty

A numeric giving the penalty coefficient for the penalization term. Alternatively, it could be either 'cv' or 'gcv' to choose the penalty using the (generalized) cross-validation criterion.

Additional options to be passed to the cv or gcv function.

Value

An object of class pspline.

Details

The penalized spline with radial basis is defined by:

$$f(x) = \beta_0 + \beta_1 x + \ldots + \beta_{m-1} x^{m-1} + \sum_{k=0}^{K-1} \beta_{m+k} || x - \kappa_k ||^{2m - 1}$$ where \(\beta_i\) are the coefficients to be estimated, \(\kappa_i\) are the coordinates of the i-th knot and \(m = \frac{d+1}{2}\) where \(d\) corresponds to the degree of the spline.

The fitting criterion is to minimize $$||y - X\beta||^2 + \lambda^{2m-1} \beta^T K \beta$$ where \(\lambda\) is the penalty coefficient and \(K\) the penalty matrix.

References

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

See Also

cv, gcv

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))
fitted <- rbpspline(y, x, knots = knots, degree = 3)
fitted

plot(x, y)
lines(fitted, col = 2)
# }

Run the code above in your browser using DataLab