This function fits the specified ordinary least squares or
parsimonious regression (plsr, pcr, ridge, and lars methods)
depending on the arguments provided, and returns estimates of
coefficients and (co-)variances in a
1 2 3 4
matrix of responses
describes the type of parsimonious
(or shrinkage) regression, or ordinary least squares.
From the pls package we have
when performing regressions,
maximal number of (principal) components to consider
method for cross validation when applying
a parsimonious regression method. The default setting
whether or not to print progress indicators. The default
"lsr") require a scheme for
estimating the amount of variability explained by increasing numbers
of non-zero coefficients (or principal components) in the model.
Towards this end, the pls and lars packages support
10-fold cross validation (CV) or leave-one-out (LOO) CV estimates of
root mean squared error. See pls and lars for
more details. The
regress function uses CV in all cases
nrow(X) <= 10, in which case CV fails and
LOO is used. Whenever
nrow(X) <= 3
plsr is used instead.
quiet = FALSE then a
is given whenever the first choice for a regression fails.
For pls methods, RMSEs
are calculated for a number of components in
NULL value for
ncomp.max it is replaced with
ncomp.max <- min(ncomp.max, ncol(y), nrow(X)-1)
which is the max allowed by the pls package.
Simple heuristics are used to select a small number of components
ncomp for pls), or number of coefficients (for
lars) which explains a large amount of the variability (RMSE).
The lars methods use a “one-standard error rule” outlined
in Section 7.10, page 216 of HTF below. The
pls package does not currently support the calculation of
standard errors for CV estimates of RMSE, so a simple linear penalty
ncomp is used instead. The ridge constant
lm.ridge is set using the
function on the
regress returns a
the components listed below.
a copy of the function call as used
a copy of the
depends on the
matrix containing the estimated regression coefficients,
(biased corrected) maximum likelihood estimate of residual covariance matrix
The CV in plsr and lars are random in nature, and so
can be dependent on the random seed. Use
deterministic (but slower) result
Be warned that the lars implementation of
"forward.stagewise" can sometimes get stuck in
(what seems like) an infinite loop.
This is not a bug in the
the bug has been reported to the authors of lars
Robert B. Gramacy firstname.lastname@example.org
Bjorn-Helge Mevik and Ron Wehrens (2007). The pls Package: Principal Component and Partial Least Squares Regression in R. Journal of Statistical Software 18(2)
Bradley Efron, Trevor Hastie, Ian Johnstone and Robert Tibshirani
Least Angle Regression (with discussion).
Annals of Statistics 32(2); see also
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
## following the lars diabetes example data(diabetes) attach(diabetes) ## Ordinary Least Squares regression reg.ols <- regress(x, y) ## Lasso regression reg.lasso <- regress(x, y, method="lasso") ## partial least squares regression reg.plsr <- regress(x, y, method="plsr") ## ridge regression reg.ridge <- regress(x, y, method="ridge") ## compare the coefs data.frame(ols=reg.ols$b, lasso=reg.lasso$b, plsr=reg.plsr$b, ridge=reg.ridge$b) ## summarize the posterior distribution of lambda2 and s2 detach(diabetes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.