Learn R Programming

refund (version 0.1-6)

wnet: Generalized elastic net in the wavelet domain

Description

Performs generalized linear scalar-on-function or scalar-on-image regression in the wavelet domain, by (naive) elastic net.

Usage

wnet(y, xfuncs, min.scale, alpha, lambda = NULL, standardize = FALSE, covt = NULL, 
     pen.covt = FALSE, filter.number = 10, wavelet.family = "DaubLeAsymm",
     family = "gaussian", nfold = 5, compare.fits = FALSE, 
     store.cv = FALSE, ...)

Arguments

y
scalar outcome vector.
xfuncs
functional predictors. For 1D predictors, an $n \times d$ matrix of signals, where $n$ is the length of y and $d$ is the number of sites at which each signal is observed. For 2D predictors, an $n \times d \times d$ array comprising $n$ images
min.scale
either a scalar, or a vector of candidate values to be compared. Used to control the coarseness level of the wavelet decomposition. The maximum value of min.scale is $log_2(d) - 1$.
alpha
elastic net mixing parameter, used by glmnet: either a scalar, or a vector of values to be compared. alpha=1 gives the lasso penalty, while alpha=0 yields the ridge penalty.
lambda
a vector of candidate regularization parameter values. If not supplied, glmnet automatically generates a sequence of candidate values.
standardize
logical, passed to glmnet: should the predictor variables be standardized? Defaults to FALSE, but either way, the coefficients are returned on the original scale.
covt
covariates, if any: an $n$-row matrix, or a vector of length $n$.
pen.covt
logical: should the scalar covariates be penalized? If FALSE (the default), penalization is suppressed by setting the appropriate components of penalty.factor to 0 in the call to glmnet<
filter.number
passed to wd or imwd, in the wavethresh package, to select the smoothness of the wavelets; defaults to 10.
wavelet.family
family of wavelets: passed to wd or imwd. Defaults to "DaubLeAsymm".
family
generalized linear model family. Current version supports "gaussian" (the default) and "binomial".
nfold
the number of validation sets ("folds") into which the data are divided.
compare.fits
logical: if TRUE, the pairwise distances among training-set coefficient function estimates are computed.
store.cv
logical: should the output include a CV result table?
...
other arguments passed to glmnet.

Value

  • A list with the following components:
  • fitted.value, residualsthe fitted values and residuals.
  • param.coefparametric coefficient estimates, for the scalar covariates.
  • fhatcoefficient function estimate.
  • Rsqcoefficient of determination.
  • min.scale,alphathe supplied value, or the one chosen by CV, for each of these arguments.
  • lambdathe lambda chosen by CV (or the specified lambda, if only a single value was supplied).
  • cv.tableif store.cv = TRUE, a table giving the CV criterion for each combination of min.scale, alpha and lambda. Otherwise, just the value for the optimized combination of min.scale, alpha and lambda.
  • stabilityif compare.fits = TRUE, a table of stability measures for each combination of min.scale, alpha and lambda. The stability measure is derived by computing the sample variance of the training-set coefficient function estimates at each point, then averaging over all points.

Details

This function supports only the standard discrete wavelet transform (see argument type in wd) with periodic boundary handling (see argument bc in wd).

References

Zhao, Y., Ogden, R. T., and Reiss, P. T. (2012). Wavelet-based LASSO in functional linear regression. Journal of Computational and Graphical Statistics, to appear.

See Also

wcr, fpcr

Examples

Run this code
### 1D functional predictor example ###

data(gasoline)

# input a single value of each tuning parameters
gas.wnet1 <- wnet(gasoline$octane, xfuncs = gasoline$NIR[,1:256], 
             min.scale = 0, alpha = 1)

# input vectors of candidate tuning parameter values
gas.wnet2 <- wnet(gasoline$octane, xfuncs = gasoline$NIR[,1:256], 
                  min.scale = 0:3, alpha = c(0.9, 1))

### 2D functional predictor example ###

n = 200; d = 64

# Create true coefficient function
ftrue = matrix(0,d,d)
ftrue[40:46,34:38] = 1

# Generate random functional predictors, and scalar responses
ii = array(rnorm(n*d^2), dim=c(n,d,d))
iimat = ii; dim(iimat) = c(n,d^2)
yy = iimat %*% as.vector(ftrue) + rnorm(n, sd=.3)

mm.wnet <- wnet(yy, xfuncs = ii, min.scale = 4, alpha = 1)

image(ftrue)
contour(mm.wnet$fhat, add=TRUE)

Run the code above in your browser using DataLab