fosr(Y = NULL, fdobj = 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)
Y
or a functional data object (class "fd"
) as in the "OLS"
for penalized ordinary least squares, "GLS"
for penalized generalized least squares, "mix"
for mixed effect models.gam
: "REML"
for restricted maximum likelihood, "GCV.Cp"
for generalized cross-validation.NULL
, the smoothing parameter(s) will be estimated. See Details.fdobj
, these arguments are ignored in FALSE
if method = "OLS"
.method = 'mix'
, the percentage of variance explained by the principal components; defaults to 0.99.method = "GLS"
.lamvec=NULL
; see lofocv
).lambda
is specified (when method = "OLS"
).X
(see scale
, to which the value of this argument is passed).fosr
, which is a list with the following elements:"fd"
representing the estimated coefficient functions. Its main components are a basis and a matrix of coefficients with respect to that basis.method = "mix"
, an object representing a functional PCA of the residuals, performed by fpca.sc
if the responses are in raw form or by pca.fd
if in functional-data-object form.method = "mix"
, an $n\times m$ matrix of random effects, where $m$ is the number of functional PC's needed to explain proportion pve
of the residual variance. These random effects can be interpreted as shrunken FPC scores.Y
and fdobj
), giving the fitted values and residuals.argvals
.argvals
.amc
.method="OLS"
, otherwise NULL
."raw"
or "fd"
, indicating whether the responses were supplied in raw or functional-data-object form.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
:NULL
, the smoothing parameter is estimated bygam
(packagemethod = "GLS"
, or byoptimize
ifmethod = "OLS"
;method = "GLS"
);method = "OLS"
; otherwise an error message is issued).multi.sp = TRUE
, then lambda
must be NULL
and method
must be "GLS"
.plot.fosr
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)
# Penalized GLS
glsmod = fosr(fdobj = Temp.fd, X = modmat, con = constraints, method="GLS")
plot(glsmod, 1)
Run the code above in your browser using DataLab