pcreg: Principal Component and Partial Least Squares Regression

Description Usage Arguments Value Author(s) See Also Examples

View source: R/pcreg.R

Description

Regression using the principal components or latent variables as inputs. The best model is selected using components 1, 2, ..., r, where r, the number of components to use is determined by the AIC or BIC.

Usage

1
pcreg(Xy, scale = TRUE, method = c("PC", "LV"), ic = c("BIC", "AIC"))

Arguments

Xy

dataframe with variable names in columns

scale

Whether or not to scale. Default is TRUE.

method

either principal components, "PC", or partial least squares latent variables, "LV"

ic

"BIC" or "AIC"

Value

An S3 class list "pcreg" with components

lmfit

lm model

PLSFit

column sd

Z

matrix of principal components or latent vector

method

'pcr' or 'pls'

Author(s)

A. I. McLeod

See Also

predict.pcreg, summary.pcreg, plot.pcreg, fitted.pcreg, residuals.pcreg

Examples

1
2
pcreg(mcdonald, scale=TRUE, method="PC")
pcreg(mcdonald, scale=TRUE, method="LV")

Example output

Loading required package: leaps

Call:
lm(formula = MORT ~ ., data = Zy[, c(1:mIC, p + 1)])

Coefficients:
(Intercept)          PC1          PC2          PC3          PC4          PC5  
   940.3584      15.5877      -3.2915     -19.8282      -2.7007      -0.7183  
        PC6          PC7  
    21.0846      17.3389  


Call:
lm(formula = MORT ~ ., data = Zy[, c(1:mIC, p + 1)])

Coefficients:
(Intercept)          LV1          LV2          LV3  
     940.36        23.60        17.40        14.91  

bestglm documentation built on March 26, 2020, 7:25 p.m.