Learn R Programming

refund (version 0.1-13)

lf: Construct an FLM regression term

Description

Defines a term $\int_{T}\beta(t)X_i(t)dt$ for inclusion in an mgcv::gam-formula (or bam or gamm or gamm4:::gamm) as constructed by pfr, where $\beta(t)$ is an unknown coefficient function and $X_i(t)$ is a functional predictor on the closed interval $T$. See smooth.terms for a list of basis and penalty options; the default is thin-plate regression splines, as this is the default option for s.

Usage

lf(X, argvals = NULL, xind = NULL, integration = c("simpson",
  "trapezoidal", "riemann"), L = NULL, presmooth = NULL,
  presmooth.opts = NULL, ...)

Arguments

X
functional predictors, typically expressed as an N by J matrix, where N is the number of columns and J is the number of evaluation points. May include missing/sparse functions, which are indicated by
argvals
indices of evaluation of X, i.e. $(t_{i1},.,t_{iJ})$ for subject $i$. May be entered as either a length-J vector, or as an N by J matrix. Indices may be unequally spaced. Entering as a matrix allows f
xind
same as argvals. It will not be supported in the next version of refund.
integration
method used for numerical integration. Defaults to "simpson"'s rule for calculating entries in L. Alternatively and for non-equidistant grids, "trapezoidal" or "riemann".
L
an optional N by ncol(argvals) matrix giving the weights for the numerical integration over t. If present, overrides integration.
presmooth
string indicating the method to be used for preprocessing functional predictor prior to fitting. Options are fpca.sc, fpca.face, fpca.ssvd, fpca.bspline, and fpca.interpolate. Defaults to
presmooth.opts
list including options passed to preprocessing method create.prep.func.
...
optional arguments for basis and penalization to be passed to mgcv::s. These could include, for example, "bs", "k", "m", etc. See s for details.

Value

  • a list with the following entries
  • calla call to te (or s, t2) using the appropriately constructed covariate and weight matrices
  • argvalsthe argvals argument supplied to lf
  • Lthe matrix of weights used for the integration
  • xindnamethe name used for the functional predictor variable in the formula used by mgcv
  • tindnamethe name used for argvals variable in the formula used by mgcv
  • LXnamethe name used for the L variable in the formula used by mgcv
  • presmooththe presmooth argument supplied to lf
  • prep.funca function that preprocesses data based on the preprocessing method specified in presmooth. See create.prep.func

References

Goldsmith, J., Bobb, J., Crainiceanu, C., Caffo, B., and Reich, D. (2011). Penalized functional regression. Journal of Computational and Graphical Statistics, 20(4), 830-851. Goldsmith, J., Crainiceanu, C., Caffo, B., and Reich, D. (2012). Longitudinal penalized functional regression for cognitive outcomes on neuronal tract measurements. Journal of the Royal Statistical Society: Series C, 61(3), 453-469.

See Also

pfr, af, mgcv's smooth.terms and linear.functional.terms; pfr for additonal examples

Examples

Run this code
data(DTI)
DTI1 <- DTI[DTI$visit==1 & complete.cases(DTI),]

# We can apply various preprocessing options to the DTI data
fit1 <- pfr(pasat ~ lf(cca, k=30), data=DTI1)
fit2 <- pfr(pasat ~ lf(cca, k=30, presmooth="fpca.sc",
                       presmooth.opts=list(nbasis=8, pve=.975)), data=DTI1)
fit3 <- pfr(pasat ~ lf(cca, k=30, presmooth="fpca.face",
                       presmooth.opts=list(m=3, npc=9)), data=DTI1)
fit4 <- pfr(pasat ~ lf(cca, k=30, presmooth="fpca.ssvd"), data=DTI1)
fit5 <- pfr(pasat ~ lf(cca, k=30, presmooth="bspline",
                       presmooth.opts=list(nbasis=8)), data=DTI1)
fit6 <- pfr(pasat ~ lf(cca, k=30, presmooth="interpolate"), data=DTI1)

# All models should result in similar fits
fits <- as.data.frame(lapply(1:6, function(i)
  get(paste0("fit",i))$fitted.values))
names(fits) <- c("none", "fpca.sc", "fpca.face", "fpca.ssvd", "bspline", "interpolate")
pairs(fits)

Run the code above in your browser using DataLab