Learn R Programming

Compositional (version 1.0)

pcr.tune: Tuning of the principal components regression

Description

Tuning the number of principal components in the principal components regression.

Usage

pcr.tune(y, x, M = 10, maxk = 50, seed = FALSE, ncores = 2)

Arguments

y
A real valued vector.
x
The predictor variables, they have to be continuous.
M
The number of folds in the cross validation.
maxk
The maximum number of principal components to check.
seed
If seed is TRUE the folds will always be the same.
ncores
The number of cores to use. If more than 1, parallel computing takes place.

Value

  • A list including:
  • mspeA vector with the mean squared error of prediction (MSPE), each value corresponds to a number of principal components.
  • kThe number of principal components which minimizes the MSPE.
  • performanceThe bias corrected lowest value of the MSPE along with the estimated bias via the Tibshirani and Tibshirani (2009) suggestion.

Details

Cross validation is performed to select the optimal number of principal components in the regression. This is used by alfapcr.tune.

References

Jolliffe I.T. (2002). Principal Component Analysis. Tibshirani and Tibshirani (2009). A bias correction for the minimum error rate in cross-validation. The Annals of Applied Statistics, 3(1):822-829.

See Also

glmpcr.tune, glm.pcr, alfa.pcr, alfapcr.tune

Examples

Run this code
library(MASS) 
x <- fgl[, 2:9]
y <- fgl[, 1]
pcr.tune(y, x, M = 10, maxk = 50, seed = FALSE, ncores = 1)

Run the code above in your browser using DataLab