Univariate P-spline smoothing with the smoothing parameter selected by leave-one-subject-out cross validation.
pspline(data, argvals.new =NULL, knots =35, p =3, m =2, lambda =NULL, search.length =100, lower =-20, upper =20)
Arguments
data: a data frame with three arguments: (1) argvals: observation times; (2) subj: subject indices; (3) y: values of observations. Missing values not allowed.
argvals.new: a vector of observations times for prediction; if NULL, then the same as data$argvals.
knots: a vector of interior knots or the number of knots for B-spline basis functions to be used; defaults to 35.
p: the degrees of B-splines; defaults to 3.
m: the order of differencing penalty; defaults to 2.
lambda: the value of the smoothing parameter; defaults to NULL.
search.length: the number of equidistant (log scale) smoothing parameters to search; defaults to 100.
lower, upper: bounds for log smoothing parameter; defaults are -20 and 20.
Details
The function is an implementation of the P-spline smoothing in Eilers and Marx (1996). P-splines uses B-splines as basis functions and employs a differencing penalty on the coefficients. Leave-one-subject-out cross validation is used for selecting the smoothing parameter and a fast algorithm is implemented.
Returns
fitted.values: Fitted mean values
B: B-spline design matrix
theta: Estimated coefficients
s: Eigenvalues
knots: Knots
p: The degrees of B-splines
m: The order of differencing penalty
lambda: The value of the smoothing parameter
argvals.new: A vector of observations times
mu.new: Fitted mean values at argvals.new
References
Paul Eilers and Brian Marx, Flexible smoothing with B-splines and penalties, Statist. Sci., 11, 89-121, 1996.
Luo Xiao, Cai Li, William Checkley and Ciprian Crainiceanu, Fast covariance estimation for sparse functional data, Stat. Comput., tools:::Rd_expr_doi("10.1007/s11222-017-9744-8") .