PenS {PFLR} | R Documentation |
Penalized B-splines Regression Model
Description
Calculates a functional regression model using the penalized B-splines method.
Usage
PenS(Y, X, alpha, M, d, domain)
Arguments
Y |
Vector of length n. |
X |
Matrix of n x p, covariate matrix, should be dense. |
alpha |
Vector. |
M |
Integer, t1,..., tM are M equally spaced knots. |
d |
Integer, the degree of B-Splines. |
domain |
The range over which the function X(t) is evaluated and the coefficient function |
Value
beta: Estimated \beta
(t) at discrete points.
extra: List containing other values which may be of use:
b: Estimated B-spline coefficients.
Ymean: Mean of the Y values.
Xmean: Mean of all X values.
Optalpha: Optimal alpha value chosen.
M: Integer representing the number of knots used in the model calculation.
d: Integer, degree of B-Splines used.
domain: The range over which the function X(t) was evaluated and the coefficient function
\beta
(t) was expanded by the B-spline basis functions.
Examples
library(fda)
betaind = 1
snr = 2
nsim = 1
n = 50
p = 21
Y = array(NA,c(n,nsim))
X = array(NA,c(n,p,nsim))
domain = c(0,1)
M = 20
d = 3
alpha = 10^(-(10:3))
for(itersim in 1:nsim)
{
dat = ngr.data.generator.bsplines(n=n,nknots=64,norder=4,p=p,domain=domain,snr=snr,betaind=betaind)
Y[,itersim] = dat$Y
X[,,itersim] = dat$X
}
psfit = PenS(Y=Y[1:n,1],X=(X[1:n,,1]), alpha=alpha, M=M, d=d, domain=domain)