rsquaredacademy / olsrr

Tools for developing OLS regression models
https://olsrr.rsquaredacademy.com/
Other
102 stars 22 forks source link

ols_step_best_subset unable to force more than one variable in selection process #210

Open jorgevallejo opened 4 months ago

jorgevallejo commented 4 months ago

Reading the documentation for function ols_step_best_subset, I understand that it is possible to force several variables in the selection process through the argument include. The argument would accept a character or numeric vector.

It works as expected when providing only one variable. But for vectors of more than one variable, only the first one is forced in the selection process.

A warning message is returned along with the results of the selection:

Warning message:
In grep(include, predicts) :
  argument 'pattern' has length > 1 and only the first element will be used

I am using version 0.6.0 of olsrr package, version 4.3.1 of R, RStudio 2022.07.0 Build 548 on Windows 10.

Reproducible example using dataset mtcars:

library(olsrr)

data(mtcars)

mtcars.lm <- lm(mpg ~ ., data = mtcars)

ols_step_best_subset(model = mtcars.lm,
                     include = c('cyl','disp'),
                     metric = 'aic')