Learn R Programming

ssym (version 1.5.1)

psp: Tool to build incidence and penalty matrices in order to approximate smooth functions by natural cubic splines.

Description

psp is used to build the incidence matrix, the penalty matrix as well as other interest matrices to approximate functions by natural cubic splines.

Usage

psp(xx, lambda, nknots, diff)

Arguments

xx
values of 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 having 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 Matrix
M <- attr(t2, "K") ## Penalty Matrix

Run the code above in your browser using DataLab