rsquaredacademy / olsrr

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

olsrr not working when I scale a model term 10 times. #207

Closed ashimkapoor closed 1 month ago

ashimkapoor commented 12 months ago

my-data-set.txt

When I run the same command after scaling a variable 10 times the same incantation fails.


# This works:

> model.1  <- lm(I(Var.One/Var4)~ I(Var2) + Var3, sample.frame)
> ols_step_best_subset(model.1)
  Best Subsets Regression
---------------------------
Model Index    Predictors
---------------------------
     1         Var3
     2         I(Var2) Var3
---------------------------

                                                        Subsets
Regression Summary
------------------------------------------------------------------------------------------------------------------------------------------
                       Adj.        Pred
Model    R-Square    R-Square    R-Square      C(p)          AIC
    SBIC            SBC         MSEP      FPE       HSP       APC
------------------------------------------------------------------------------------------------------------------------------------------
  1        0.0281      0.0277      0.0258    704.9243    -86740.1911
 -94789.2817    -86722.3406    0.0000    0.0000    0.0000    0.9733
  2        0.0347      0.0339      0.0315      3.0000    -78463.9389
 -85692.0048    -78440.5683    0.0000    0.0000    0.0000    0.9676
------------------------------------------------------------------------------------------------------------------------------------------
AIC: Akaike Information Criteria
 SBIC: Sawa's Bayesian Information Criteria
 SBC: Schwarz Bayesian Criteria
 MSEP: Estimated error of prediction, assuming multivariate normality
 FPE: Final Prediction Error
 HSP: Hocking's Sp
 APC: Amemiya Prediction Criteria

This does not work:

> model.2  <- lm(I(Var.One/Var4)~ I(10*Var2) + Var3, sample.frame)
> ols_step_best_subset(model.2)
Error in eval(predvars, data, env) : object 'Var.One' not found
>

Please notice that only difference between model.1 and model.2 is that Var2 is replaced by 10 * Var2.

I have attached my dataset.

ashimkapoor commented 12 months ago

Dear All,

The error disappears on upgrading R from 4.3.0 -> 4.3.1.