Learn R Programming

ssym (version 1.5.2)

psp: Tool to build B-spline basis and penalty matrices, which can be used to approximate functions by P-splines.

Description

psp builds the B-spline basis and penalty matrices.

Usage

psp(xx, lambda, nknots, diff)

Arguments

xx
the explanatory variable.
lambda
an optional positive value, which corresponds to the smoothing parameter.
nknots
an optional integer specifying the number of internal knots. Defaul is $[n^(1/3)]$
diff
an optional integer specifying the order of the difference penalty term. Default is 2.

Value

  • xxa matrix with the following attributes: B-spline basis matrix, penalty matrix, and smoothing parameter (if it has been specified).

References

Eilers P.H.C. and Marx B.D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science. 11, 89-121.

Examples

Run this code
n <- 300
t <- sort(round(runif(n),digits=2))

t2 <- psp(t, diff=3)
N <- attr(t2, "N") ## B-spline basis matrix
M <- attr(t2, "K") ## Penalty Matrix

Run the code above in your browser using DataLab