rsquaredacademy / olsrr

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

Output of the command "ols_step_both_aic" doesn't contain final model #201

Closed SunsetBlvd closed 2 years ago

SunsetBlvd commented 2 years ago

Good day! Looks like that output of the command "ols_step_both_aic" doesn't contain final model.

model <- lm(y ~ ., data = stepdata)
k <- ols_step_both_aic(model)
k$model

NULL

aravindhebbali commented 2 years ago

Hi.. we have fixed this in the development version of olsrr.

# Install development version from GitHub
# install.packages("devtools")
devtools::install_github("rsquaredacademy/olsrr")
library(olsrr)
#> 
#> Attaching package: 'olsrr'
#> The following object is masked from 'package:datasets':
#> 
#>     rivers
model <- lm(y ~ ., data = stepdata)
k <- ols_step_both_aic(model)
k$model
#> 
#> Call:
#> lm(formula = paste(response, "~", paste(preds, collapse = " + ")), 
#>     data = l)
#> 
#> Coefficients:
#> (Intercept)           x1           x3           x2           x4  
#>   -0.005326     0.255351     0.252538     0.248762    -0.006616

Created on 2022-08-08 by the reprex package (v0.3.0)

SunsetBlvd commented 2 years ago

OK, thank you!