Learn R Programming

refund (version 0.1-3)

pfr: Penalized Functional Regression

Description

Implements penalized functional regression (Goldsmith et al. 2011) for generalized linear functional models with scalar outcomes.

Usage

pfr(Y, covariates = NULL, funcs, kz = 30, kb = 30, smooth.cov = FALSE, family = "gaussian", ...)

Arguments

Y
Length n vector of outcomes
covariates
n by p matrix of scalar covariates
funcs
n by N matrix of observed functional predictors
kz
Dimension of principal components basis for the observed functional predictors
kb
Dimension of the truncated power series spline basis for the coefficient function
smooth.cov
Logical; do you wish to smooth the covariance matrix of observed functions? Increases computation time, but results in smooth principal components
family
Generalized linear model family
...
Additional arguments passed to the gam function to fit the regression model.

Value

  • gamThe result of the call to gam
  • fitted.valsPredicted outcomes
  • betaHatEstimated coefficient function
  • beta.covariatesParameter estimates for scalar covariates
  • XDesign matrix used in the model fit
  • phiTruncated power series spline basis for the coefficient function
  • psiPrincipal components basis for the functional predictors
  • varBetaHatCovariance matrix for the estimated coefficient function
  • BoundsBounds of a 95% confidence interval for the estimated coefficient function

References

Goldsmith, J., Bobb, J., Crainiceanu, C., Caffo, B., and Reich, D. (2011). Penalized functional regression. Journal of Computational and Graphical Statistics, to appear.

Examples

Run this code
##### Octane Data Example #####
data(gasoline)
Y = gasoline$octane
funcs = gasoline$NIR
wavelengths = 2*450:850

# fit the model using pfr
fit = pfr(Y=Y, funcs=funcs, kz=50, kb=50)

# plot the estimated coefficient function
matplot(wavelengths, cbind(fit$betaHat, fit$Bound), type='l', lwd=c(2,1,1), 
    lty=c(1,2,2), xlab = "Wavelengths", ylab = "Coefficient Function", col=1)

Run the code above in your browser using DataLab