So anyone remember these series of threads from 2020?:
- tidymodels alternatives to stepwise regression
- generalized linear model - What are modern, easily used alternatives to stepwise regression? - Cross Validated
- Stepwise regression in tidymodels
- r - Stepwise Algorithm in Tidymodels - Stack Overflow
Why use stepwise when there are so many better alternatives? Because your boss tells you to.
I decided to God's work. To make my own custom model for at least one type of stepwise regression, if only to convince people that there are better tidymodels functions out there. This way no person out there has an excuse even not to use tidymodels.
I am following the directions from Learn - How to build a parsnip model to make my own package. What I am stuck on is for qualitative models how can I specify the values.
I would like to make a dial's like construtor for forward/backward selection. However, that is a text parameter. So I am not sure how to set up these constructor arguments to limit new values.
A function reference for a constructor that will be used to generate tuning parameter values. This should be a character vector with a named element called
funthat is the constructor function. There is an optional element
pkgthat can be used to call the function using its namespace. If referencing functions from the dials package, quantitative parameters can have additional arguments in the list for
rangewhile qualitative parameters can pass
valuesvia this list.
# Part Zero define some necessary pre-model depednancies step_direction <- dials::new_qual_param( type = "character", values =c("both", "backward", "forward"), label = c(step_direction = "direction"), finalize = NULL ) # set the likelihood function for AIC / BIC. I prefer 2 for AIC to keep it simple # 8 was picked because log2(256) is 8 and my data is near n = 256 step_likely <- dials::new_qual_param( type = "double", range = c(2,8), trans = NULL, inclusive = c(TRUE, TRUE), label = c(step_likely = "k"), finalize = NULL )
Edit: Updated the question for clarification