Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pcr

Principal components regression


Description

Principal components regression.

Usage

pcr(y, x, k = 1, xnew = NULL)

Arguments

y

A real values vector.

x

A matrix with the predictor variable(s), they have to be continuous.

k

The number of principal components to use. This can be a single number or a vector starting from 1. In the second case you get results for the sequence of principal components.

xnew

If you have new data use it, otherwise leave it NULL.

Details

The principal components of the cross product of the independent variables are obtained and classical regression is performed.

Value

A list including:

be

The beta coefficients of the predictor variables computed via the principcal components.

per

The percentage of variance of the cross product of the independent variables explained by the k components.

vec

The principal components, the loadings.

est

The fitted or the predicted values (if xnew is not NULL).

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

References

Jolliffe I.T. (2002). Principal Component Analysis.

See Also

Examples

y <- as.vector(iris[, 1])
x <- as.matrix(iris[, 2:4])
mod1 <- pcr(y, x, 1)
mod2 <- pcr(y, x, 2)
mod <- pcr(y, x, k = 1:3)  ## all results at once

Rfast2

A Collection of Efficient and Extremely Fast R Functions II

v0.0.9
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Stefanos Fafalios and Marios Dimitriadis.
Initial release
2021-03-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.