dot-fit.pcr: Principal Components Regression for 'tidyfit'

.fit.pcrR Documentation

Principal Components Regression for tidyfit

Description

Fits a principal components regression on a 'tidyFit' R6 class. The function can be used with regress.

Usage

## S3 method for class 'pcr'
.fit(self, data = NULL)

Arguments

self

a 'tidyFit' R6 class.

data

a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

Details

Hyperparameters:

  • ncomp (number of components)

  • ncomp_pct (number of components, percentage of features)

Important method arguments (passed to m)

The principal components regression is fitted using pls package. See ?pcr for more details.

Implementation

Covariates are standardized, with coefficients back-transformed to the original scale. An intercept is always included.

If no hyperparameter grid is passed (is.null(control$ncomp) & is.null(control$ncomp_pct)), the default is ncomp_pct = seq(0, 1, length.out = 20), where 0 results in one component and 1 results in the number of features.

When 'jackknife = TRUE' is passed (and a 'validation' method is chosen), coef also returns the jack-knife standard errors, t-statistics and p-values.

Note that at present pls does not offer weighted implementations or non-gaussian response. The method can therefore only be used with regress

Value

A fitted 'tidyFit' class model.

Author(s)

Johann Pfitzinger

References

Liland K, Mevik B, Wehrens R (2022). pls: Partial Least Squares and Principal Component Regression. R package version 2.8-1, https://CRAN.R-project.org/package=pls.

See Also

.fit.plsr and m methods

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::filter(data, Industry == "HiTec")
data <- dplyr::select(data, -Industry)

# Stand-alone function
fit <- m("pcr", Return ~ ., data, ncomp = 1:3)
fit

# Within 'regress' function
fit <- regress(data, Return ~ .,
               m("pcr", jackknife = TRUE, validation = "LOO", ncomp_pct = 0.5),
               .mask = c("Date"))
tidyr::unnest(coef(fit), model_info)


tidyfit documentation built on April 4, 2025, 4:38 a.m.