Automated selection of model parameters
This function performs an automated selection of the 'best' parameters, updating and returning the "best" model.
select_parameters(model, ...) ## S3 method for class 'lm' select_parameters(model, direction = "both", steps = 1000, k = 2, ...) ## S3 method for class 'merMod' select_parameters(model, direction = "backward", steps = 1000, ...) ## S3 method for class 'stanreg' select_parameters(model, method = NULL, cross_validation = FALSE, ...)
model |
A statistical model (of class |
... |
Arguments passed to or from other methods. |
direction |
the mode of stepwise search, can be one of |
steps |
the maximum number of steps to be considered. The default is 1000 (essentially as many as required). It is typically used to stop the process early. |
k |
the multiple of the number of degrees of freedom used for the penalty.
Only |
method |
The method used in the variable selection. Can be |
cross_validation |
Select with cross-validation. |
For frequentist GLMs, select_parameters()
performs an AIC-based
stepwise selection.
For mixed-effects models of class merMod
, stepwise selection is
based on stepcAIC()
. This step function
only searches the "best" model based on the random-effects structure,
i.e. select_parameters()
adds or excludes random-effects until
the cAIC can't be improved further.
For Bayesian models, it uses the projpred package.
The model refitted with optimal number of parameters.
model <- lm(mpg ~ ., data = mtcars) select_parameters(model) model <- lm(mpg ~ cyl * disp * hp * wt, data = mtcars) select_parameters(model) # lme4 ------------------------------------------- if (require("lme4")) { model <- lmer( Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), data = iris ) select_parameters(model) } ## Not run: # rstanarm ------------------------------------------- if (require("rstanarm") && require("projpred")) { model <- stan_glm( mpg ~ ., data = mtcars, iter = 500, refresh = 0, verbose = FALSE ) select_parameters(model, cross_validation = TRUE) model <- stan_glm( mpg ~ cyl * disp * hp, data = mtcars, iter = 500, refresh = 0, verbose = FALSE ) select_parameters(model, cross_validation = FALSE) } ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.