rsquaredacademy / olsrr

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

`plot()` with `ols_step_both_aic()` doesn't show anything when AIC values are negative. #212

Open williamlai2 opened 3 months ago

williamlai2 commented 3 months ago

I provide a reprex for this as the object doesn't seem to be able to be written out properly, but when the AIC values are negative, then plot() doesn't work properly. The limits need to be manually reversed.

                                           Stepwise Summary                                           
----------------------------------------------------------------------------------------------------
Step    Variable                      AIC             SBC             SBIC          R2       Adj. R2 
----------------------------------------------------------------------------------------------------
 0      Base Model                 -985484.600     -985461.939    -2733547.341    0.00000    0.00000 
 1      VEGETATION (+)            -1304585.845    -1304472.535    -3052661.699    0.40433    0.40432 
 2      watertableslice (+)       -1376953.606    -1376828.965    -3125029.022    0.47036    0.47035 
 3      LANDFORM (+)              -1381566.411    -1381373.784    -3129651.797    0.47432    0.47431 
 4      MrVBF_class (+)           -1384577.316    -1384339.365    -3132668.669    0.47689    0.47688 
 5      dist_to_perm_water (+)    -1386032.813    -1385783.532    -3134124.143    0.47813    0.47811 
 6      depth_to_gw (+)           -1386277.748    -1386017.136    -3134369.074    0.47834    0.47832 
----------------------------------------------------------------------------------------------------
plot(mod1)

image

plot(mod1) +
  # because it is negative
  scale_y_continuous(limits = c(min(mod1$metrics$aic), max(mod1$metrics$aic)))

image