
Genetic algorithm with linear regression fitness evaluator for tidyfit
Source: R/fit.genetic.R
dot-fit.genetic.Rd
Fits a linear regression with variable selection using a genetic algorithm on a 'tidyFit' R6
class. The function can be used with regress
.
Details
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
statistic
populationSize
numGenerations
minVariables
maxVariables
The function provides a wrapper for gaselect::genAlg
. See ?genAlg
for more details.
Implementation
Control arguments are passed to gaselect::genAlgControl (the function automatically identifies which arguments are for the control object, and which for gaselect::genAlg).
gaselect::evaluatorLM is used as the evaluator with the relevant arguments automatically identified by the function.
References
Kepplinger D (2023). gaselect: Genetic Algorithm (GA) for Variable Selection from High-Dimensional Data. R package version 1.0.21, https://CRAN.R-project.org/package=gaselect.
See also
.fit.lm
, .fit.bayes
and m
methods
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
# Generally used inside 'regress' function
fit <- regress(data, Return ~ ., m("genetic", statistic = "BIC"),
.mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 6 × 4
#> # Groups: model [1]
#> model term estimate model_info
#> <chr> <chr> <dbl> <list>
#> 1 genetic (Intercept) -0.0243 <tibble [1 × 3]>
#> 2 genetic Mkt-RF 0.979 <tibble [1 × 3]>
#> 3 genetic HML 0.0628 <tibble [1 × 3]>
#> 4 genetic RMW 0.156 <tibble [1 × 3]>
#> 5 genetic CMA 0.114 <tibble [1 × 3]>
#> 6 genetic RF 0.997 <tibble [1 × 3]>