我正在使用 R 运行逐步前向回归,但我不知道模型如何逐步演化。我正在寻找一个输出(逐步)展示模型如何从 1 个预测变量增长直到停止增长。
我使用的语法是:
# Initialize model
forward_model <- lm(NPS ~ ., data = SAMBANDSANALYSER)
# Forward stepwise regression
forward_model <- step(forward_model, direction = "forward", scope = formula(~ .))
我正在寻找这样的结果。这是向后回归的步骤。
对于前进步骤,您从空模型开始:
lm1 <- lm(Fertility ~ 1, data = swiss)
step(lm1, direction="forward", scope=formula(lm(Fertility ~ ., data = swiss)))
Start: AIC=238.35
Fertility ~ 1
Df Sum of Sq RSS AIC
+ Education 1 3162.7 4015.2 213.04
+ Examination 1 2994.4 4183.6 214.97
+ Catholic 1 1543.3 5634.7 228.97
+ Infant.Mortality 1 1245.5 5932.4 231.39
+ Agriculture 1 894.8 6283.1 234.09
<none> 7178.0 238.34
Step: AIC=213.04
Fertility ~ Education
Df Sum of Sq RSS AIC
+ Catholic 1 961.07 3054.2 202.18
+ Infant.Mortality 1 891.25 3124.0 203.25
+ Examination 1 465.63 3549.6 209.25
<none> 4015.2 213.04
+ Agriculture 1 61.97 3953.3 214.31
...