fosr {refund} | R Documentation |
Function-on-scalar regression
Description
Fit linear regression with functional responses and scalar predictors, with efficient selection of optimal smoothing parameters.
Usage
fosr(
formula = NULL,
Y = NULL,
fdobj = NULL,
data = NULL,
X,
con = NULL,
argvals = NULL,
method = c("OLS", "GLS", "mix"),
gam.method = c("REML", "ML", "GCV.Cp", "GACV.Cp", "P-REML", "P-ML"),
cov.method = c("naive", "mod.chol"),
lambda = NULL,
nbasis = 15,
norder = 4,
pen.order = 2,
multi.sp = ifelse(method == "OLS", FALSE, TRUE),
pve = 0.99,
max.iter = 1,
maxlam = NULL,
cv1 = FALSE,
scale = FALSE
)
Arguments
formula |
Formula for fitting fosr. If used, data argument must not be null. |
Y , fdobj |
the functional responses, given as either an |
data |
data frame containing the predictors and responses. |
X |
the model matrix, whose columns represent scalar predictors. Should ordinarily include a column of 1s. |
con |
a row vector or matrix of linear contrasts of the coefficient functions, to be constrained to equal zero. |
argvals |
the |
method |
estimation method: |
gam.method |
smoothing parameter selection method, to be passed to
|
cov.method |
covariance estimation method: the current options are naive or modified Cholesky. See Details. |
lambda |
smoothing parameter value. If |
nbasis , norder |
number of basis functions, and order of splines (the
default, 4, gives cubic splines), for the B-spline basis used to represent
the coefficient functions. When the functional responses are supplied using
|
pen.order |
order of derivative penalty. |
multi.sp |
a logical value indicating whether separate smoothing
parameters should be estimated for each coefficient function. Currently
must be |
pve |
if |
max.iter |
maximum number of iterations if |
maxlam |
maximum smoothing parameter value to consider (when
|
cv1 |
logical value indicating whether a cross-validation score should
be computed even if a single fixed |
scale |
logical value or vector determining scaling of the matrix
|
Details
The GLS method requires estimating the residual covariance matrix, which
has dimension d\times d
when the responses are given by Y
, or
nbasis\times nbasis
when they are given by fdobj
. When
cov.method = "naive"
, the ordinary sample covariance is used. But
this will be singular, or nonsingular but unstable, in high-dimensional
settings, which are typical. cov.method = "mod.chol"
implements the
modified Cholesky method of Pourahmadi (1999) for estimation of covariance
matrices whose inverse is banded. The number of bands is chosen to maximize
the p-value for a sphericity test (Ledoit and Wolf, 2002) applied to the
"prewhitened" residuals. Note, however, that the banded inverse covariance
assumption is sometimes inappropriate, e.g., for periodic functional
responses.
There are three types of values for argument lambda
:
-
if
NULL
, the smoothing parameter is estimated bygam
(package mgcv) ifmethod = "GLS"
, or byoptimize
ifmethod = "OLS"
; if a scalar, this value is used as the smoothing parameter (but only for the initial model, if
method = "GLS"
);if a vector, this is used as a grid of values for optimizing the cross-validation score (provided
method = "OLS"
; otherwise an error message is issued).
Please note that currently, if multi.sp = TRUE
, then lambda
must be NULL
and method
must be "GLS"
.
Value
An object of class fosr
, which is a list with the following
elements:
fd |
object of class |
pca.resid |
if
|
U |
if |
yhat , resid |
objects of the same
form as the functional responses (see arguments |
est.func |
matrix of values
of the coefficient function estimates at the points given by
|
se.func |
matrix of values of the standard error
estimates for the coefficient functions, at the points given by
|
argvals |
points at which the coefficient functions are evaluated. |
fit |
fit object outputted by |
edf |
effective degrees of freedom of the fit. |
lambda |
smoothing parameter, or vector of smoothing parameters. |
cv |
cross-validated integrated squared error if |
roughness |
value of the roughness penalty. |
resp.type |
|
Author(s)
Philip Reiss phil.reiss@nyumc.org, Lan Huo, and Fabian Scheipl
References
Ledoit, O., and Wolf, M. (2002). Some hypothesis tests for the covariance matrix when the dimension is large compared to the sample size. Annals of Statistics, 30(4), 1081–1102.
Pourahmadi, M. (1999). Joint mean-covariance models with applications to longitudinal data: unconstrained parameterisation. Biometrika, 86(3), 677–690.
Ramsay, J. O., and Silverman, B. W. (2005). Functional Data Analysis, 2nd ed., Chapter 13. New York: Springer.
Reiss, P. T., Huang, L., and Mennes, M. (2010). Fast function-on-scalar regression with penalized basis expansions. International Journal of Biostatistics, 6(1), article 28. Available at https://pubmed.ncbi.nlm.nih.gov/21969982/
See Also
Examples
## Not run:
require(fda)
# The first two lines, adapted from help(fRegress) in package fda,
# set up a functional data object representing daily average
# temperatures at 35 sites in Canada
daybasis25 <- create.fourier.basis(rangeval=c(0, 365), nbasis=25,
axes=list('axesIntervals'))
Temp.fd <- with(CanadianWeather, smooth.basisPar(day.5,
dailyAv[,,'Temperature.C'], daybasis25)$fd)
modmat = cbind(1, model.matrix(~ factor(CanadianWeather$region) - 1))
constraints = matrix(c(0,1,1,1,1), 1)
# Penalized OLS with smoothing parameter chosen by grid search
olsmod = fosr(fdobj = Temp.fd, X = modmat, con = constraints, method="OLS", lambda=100*10:30)
plot(olsmod, 1)
# Test use formula to fit fosr
set.seed(2121)
data1 <- pffrSim(scenario="ff", n=40)
formod = fosr(Y~xlin+xsmoo, data=data1)
plot(formod, 1)
# Penalized GLS
glsmod = fosr(fdobj = Temp.fd, X = modmat, con = constraints, method="GLS")
plot(glsmod, 1)
## End(Not run)