.fit.subset {tidyfit}R Documentation

Best subset regression and classification for tidyfit

Description

Fits a best subset regression or classification on a 'tidyFit' R6 class. The function can be used with regress and classify.

Usage

## S3 method for class 'subset'
.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:

None. Cross validation not applicable.

Important method arguments (passed to m)

The best subset regression is estimated using bestglm::bestglm which is a wrapper around leaps::regsubsets for the regression case, and performs an exhaustive search for the classification case. See ?bestglm for more details.

Implementation

Forward or backward selection can be performed by passing method = "forward" or method = "backward" to m.

Value

A fitted 'tidyFit' class model.

Author(s)

Johann Pfitzinger

References

A.I. McLeod, Changjiang Xu and Yuanhao Lai (2020). bestglm: Best Subset GLM and Regression Utilities. R package version 0.37.3. URL https://CRAN.R-project.org/package=bestglm.

See Also

.fit.lm and m methods

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns

# Stand-alone function
fit <- m("subset", Return ~ ., data, method = c("forward", "backward"))
tidyr::unnest(fit, settings)

# Within 'regress' function
fit <- regress(data, Return ~ ., m("subset", method = "forward"),
               .mask = c("Date", "Industry"))
coef(fit)


[Package tidyfit version 0.7.1 Index]