Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upall possible regression fails when model formula contains inline functions or interaction variables #4
Comments
|
> library(olsrr)
> library(caret)
> data("Sacramento")
> lm_fit2 <- lm(price ~ beds + baths + log(sqft), data = Sacramento)
> ols_all_subset(lm_fit2)
Index N Predictors R-Square Adj. R-Square Mallow's Cp
1 1 1 log(sqft) 0.568 0.567 52.6943
2 2 1 baths 0.331 0.331 589.5143
3 3 1 beds 0.215 0.214 854.1735
4 4 2 beds log(sqft) 0.591 0.59 2.9559
5 5 2 baths log(sqft) 0.568 0.567 54.5318
6 6 2 beds baths 0.344 0.343 562.4425
7 7 3 beds baths log(sqft) 0.591 0.59 4
# interaction variables
> lm_fit3 <- lm(mpg ~ disp + hp + wt + am * disp, data = mtcars)
> ols_all_subset(lm_fit3)
Index N Predictors R-Square Adj. R-Square Mallow's Cp
1 1 1 wt 0.753 0.745 15.7814
2 2 1 disp 0.718 0.709 21.8906
3 3 1 hp 0.602 0.589 42.4214
4 4 1 am 0.36 0.338 85.4006
5 5 1 disp:am 0.025 -0.008 144.7555
6 6 2 hp wt 0.827 0.815 4.682
7 7 2 hp am 0.782 0.767 12.6088
8 8 2 disp wt 0.781 0.766 12.8044
9 9 2 wt disp:am 0.779 0.764 13.1616
10 10 2 wt am 0.753 0.736 17.7811
11 11 2 disp hp 0.748 0.731 18.5949
12 12 2 disp am 0.733 0.715 21.2358
13 13 2 hp disp:am 0.723 0.703 23.1505
14 14 2 disp disp:am 0.719 0.699 23.8295
15 15 2 am disp:am 0.642 0.618 37.3666
16 16 3 hp wt am 0.84 0.823 4.3607
17 17 3 wt am disp:am 0.83 0.812 6.0674
18 18 3 disp hp wt 0.827 0.808 6.673
19 19 3 hp wt disp:am 0.827 0.809 6.573
20 20 3 disp hp am 0.799 0.778 11.5672
21 21 3 disp wt disp:am 0.796 0.774 12.1161
22 22 3 disp am disp:am 0.79 0.767 13.2175
23 23 3 hp am disp:am 0.789 0.767 13.2901
24 24 3 disp wt am 0.781 0.758 14.7845
25 25 3 disp hp disp:am 0.764 0.739 17.7208
26 26 4 hp wt am disp:am 0.853 0.831 4.0081
27 27 4 disp hp wt am 0.84 0.817 6.3004
28 28 4 disp wt am disp:am 0.836 0.812 6.9704
29 29 4 disp hp wt disp:am 0.827 0.802 8.5727
30 30 4 disp hp am disp:am 0.811 0.783 11.5263
31 31 5 disp hp wt am disp:am 0.853 0.825 6 |
ols_all_subset()returns an error when the formula in the model contains inline functions or interaction variables.Session Info