# pcr: Principal components regression In Rfast2: A Collection of Efficient and Extremely Fast R Functions II

 Principal components regression R Documentation

## 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.

```pca ```

### 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 documentation built on May 29, 2024, 8:45 a.m.