.fit.plsr {tidyfit} | R Documentation |
Partial Least Squares Regression for tidyfit
Description
Fits a partial least squares regression on a 'tidyFit' R6
class. The function can be used with regress
.
Usage
## S3 method for class 'plsr'
.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 partial least squares regression is fitted using pls
package. See ?plsr
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
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::filter(data, Industry == "HiTec")
data <- dplyr::select(data, -Industry)
# Stand-alone function
fit <- m("plsr", 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)