spfda | R Documentation |
Function-on-scalar regression model, denote \mjseqnn as total number of observations, \mjseqnp the number of coefficients, \mjseqnK as the number of B-splines, \mjseqnT as total time points.
spfda( Y, X, lambda, time = seq(0, 1, length.out = ncol(Y)), nsp = "auto", ord = 4, alpha = 0.5, W = NULL, init = NULL, max_iter = 50, inner_iter = 50, CI = FALSE, ... )
Y |
Numeric \mjseqnn \times T matrix, response function. |
X |
Numeric \mjseqnn \times p matrix, design matrix |
lambda |
Regularization parameter \mjseqn\gamma |
time |
Time domain, numerical length of \mjseqnT |
nsp |
Integer or 'auto', number of B-splines \mjseqnK; default is 'auto' |
ord |
B-spline order, default is |
alpha |
Bridge parameter \mjseqn\alpha, default is |
W |
A \mjseqnT \times T weight matrix or |
init |
Initial \mjseqn\gamma; default is |
max_iter |
Number of outer iterations |
inner_iter |
Number of \mjseqnADMM iterations (inner steps) |
CI |
Logical, whether to calculate theoretical confidence intervals |
... |
Ignored |
This function implements "Functional Group Bridge for Simultaneous
Regression and Support Estimation" (https://arxiv.org/abs/2006.10163).
The model estimates functional coefficients \mjseqn\beta(t) under model
\mjsdeqny(t) = X\beta(t) + \epsilon(t) with B-spline basis expansion
\mjsdeqn\beta(t) = \gamma B(t) + R(t), where \mjseqn R(t) is B-spline
approximation error. The objective function
\mjsdeqn
\left\| (Y-X\gamma B)W \right\|_2^2 + \sum_j,m
\left\| \gamma_j^T\mathbf1(B^t > 0) \right\|_1^\alpha.
The input response variable is a matrix. If \mjseqny_i(t) are observed
at different time points, please interpolate (e.g.
kernel
) before feeding in.
A spfda.model
object (environment) with following elements:
B-spline basis functions used
Root Mean Square Error ('RMSE')
Whether confidence intervals are calculated
B-spline coefficient \mjseqn\gamma_p \times K
Function to generate B-splines given time points
Number of B-spline basis functions
B-spline knots used to fit the model
Function to predict responses \mjseqn\beta(t) given new
X
and/or time points
A list of raw variables
dat <- spfda_simulate() x <- dat$X y <- dat$Y fit <- spfda(y, x, lambda = 5, CI = TRUE) BIC(fit) plot(fit, col = c("orange", "dodgerblue3", "darkgreen"), main = "Fitted with 95% CI", aty = c(0, 0.5, 1), atx = c(0,0.2,0.8,1)) matpoints(fit$time, t(dat$env$beta), type = 'l', col = 'black', lty = 2) legend('topleft', c("Fitted", "Underlying"), lty = c(1,2)) print(fit) coefficients(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.