coef.mvr {pls}R Documentation

Extract Information From a Fitted PLSR or PCR Model

Description

Functions to extract the regression coefficients or the model matrix from mvr objects.

Usage

## S3 method for class 'mvr':
coef(object, comps = object$ncomp, intercept = FALSE,
     cumulative = TRUE, ...)
## S3 method for class 'mvr':
model.matrix(object, ...)

Arguments

object an mvr object. The fitted model.
comps vector of positive integers. The components to include in the coefficients. Defaults to the number of components used for fitting the model.
intercept logical. Whether coefficients for the intercept should be included. Ignored if cumulative = FALSE. Defaults to FALSE.
cumulative logical. Whether cumulative (the default) or individual coefficients for each component should be returned. See below.
... other arguments sent to underlying functions. Currently only used for model.matrix.mvr.

Details

coef.mvr is used to extract the regression coefficients of a model, i.e. the B in y = XB. An array of dimension c(nxvar, nyvar, length(comps)) is returned.

If cumulative = TRUE, coef()[,,comps[i]] are the coefficients for models with comps[i] components, for i = 1, ..., length(comps). Also, if intercept = TRUE, the first dimension is nxvar + 1, with the intercept coefficients as the first row.

If cumulative = FALSE, however, coef()[,,comps[i]] are the coefficients for a model with only the component comps[i], i.e. the contribution of the component comps[i] on the regression coefficients.

model.matrix.mvr returns the (possibly coded) matrix used as X in the fitting.

Value

coef.mvr returns an array of regression coefficients.
model.matrix.mvr returns the X matrix.

Author(s)

Ron Wehrens and Bjørn-Helge Mevik

See Also

mvr, predict.mvr, scores

Examples

data(NIR)
mod <- pcr(y ~ X, data = NIR[NIR$train,], ncomp = 5)
B <- coef(mod, comps = 3, intercept = TRUE)
## A manual predict method:
stopifnot(drop(B[1,,] + NIR$X[!NIR$train,] %*% B[-1,,]) ==
          drop(predict(mod, comps = 3, newdata = NIR[!NIR$train,])))

[Package pls version 1.0-2 Index]