Learn R Programming

refund (version 0.1-1)

af: Construct an FGAM regression term

Description

Defines a term $\int_{T}F(X_i(t),t)dt$ for inclusion in an mgcv::gam-formula (or bam or gamm or gamm4:::gamm) as constructed by fgam, where $F(x,t)$$ is an unknown smooth bivariate function and $X_i(t)$ is a functional predictor on the closed interval $T$. Defaults to a cubic tensor product B-spline with marginal second-order difference penalties for estimating $F(x,t)$. The functional predictor must be fully observed on a regular grid.

Usage

af(X, xind = seq(0, 1, l = ncol(X)), basistype = c("te","t2", "s"), 
   integration = c("simpson", "trapezoidal", "riemann"), 
   L = NULL, splinepars = list(bs = "ps", 
   k = c(min(ceiling(nrow(X)/5),20),min(ceiling(ncol(X)/5),20)),
   m = list(c(2, 2), c(2, 2))), presmooth = TRUE, Xrange=range(X), Qtransform=FALSE)

Arguments

X
an N by J=ncol(xind) matrix of function evaluations $X_i(t_{i1}),., X_i(t_{iJ}); i=1,.,N.$
xind
matrix (or vector) of indices of evaluations of $X_i(t)$; i.e. a matrix with ith row $(t_{i1},.,t_{iJ})$.
basistype
defaults to "te", i.e. a tensor product spline to represent $F(x,t)$ Alternatively, use "s" for bivariate basis functions (see mgcv's s) or "t2" for an alternative parameter
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". "riemann" integrati
L
optional: an N by ncol(xind) matrix giving the weights for the numerical integration over t.
splinepars
optional arguments specifying options for representing and penalizing the function $F(x,t)$. Defaults to a cubic tensor product B-spline with marginal second-order difference penalties, i.e. list(bs="ps", m=list(c(2, 2), c(2, 2)), see <
presmooth
If true, the functional predictor is pre-smoothed prior to fitting. See smooth.basisPar in package fda
Xrange
Range to use when specifying the marginal basis for the x-axis. It may be desired to increase this slightly over the default of range(X) if concerned about predicting for future observed curves that take values outside of rang
Qtransform
Should the functional be transformed using the empirical cdf and applying a quantile transformation on each column of X prior to fitting? This ensures Xrange=c(0,1). If Qtransform=TRUE and presmooth=TRUE

Value

  • A list with the following entries:
  • calla "call" to te (or s, t2) using the appropriately constructed covariate and weight matrices.
  • xindthe xind argument supplied to af.
  • 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 xind variable in the formula used by mgcv.
  • Lnamethe name used for the L variable in the formula used by mgcv.
  • presmooththe presmooth argument supplied to af.
  • Qtranformthe Qtransform argument supplied to af.
  • Xrangethe Xrange argument supplied to af.
  • ecdflista list containing one empirical cdf function from applying ecdf to each (possibly presmoothed) column of X. Only present if Qtransform=TRUE.
  • Xfdan fd object from presmoothing the functional predictors using smooth.basisPar. Only present if presmooth=TRUE. See fd.

References

McLean, M. W., Hooker, G., Staicu, A.-M., Scheipl, F., and Ruppert, D. (2013). Functional generalized additive models. Journal of Computational and Graphical Statistics, to appear. Available at http://courses2.cit.cornell.edu/mwmclean

See Also

fgam, lf, mgcv's linear.functional.terms, fgam for examples.