Tuning of the principal components regression: 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, mat = NULL, ncores = 1, graph = TRUE)
Arguments
y
A real valued vector.
x
A matrix with 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.
mat
You can specify your own folds by giving a mat, where each column is a fold. Each column contains indices of the observations.
You can also leave it NULL and it will create folds.
ncores
The number of cores to use. If more than 1, parallel computing will take place. It is advisable to use it if you have many
observations and or many variables, otherwise it will slow down th process.
graph
If graph is TRUE a plot of the performance for each fold along the values of \(\alpha\) will appear.
Value
A list including:
If graph is TRUE a plot of the performance versus the number of principal components will appear.
msp
A matrix with the mean squared error of prediction (MSPE) for every fold.
mspe
A vector with the mean squared error of prediction (MSPE), each value corresponds to a number of principal components.
k
The number of principal components which minimizes the MSPE.
performance
The lowest value of the MSPE.
runtime
The time required by the cross-validation procedure.
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.