I am having problem using the step function for a linear regression model. I've created an initial model containing only the intercept. Then using the step function, I've selected three variables to be considered for the model.
x0.lm<- lm(MEDV~1, data = x)
anova(x0.lm)
Analysis of Variance Table
Response: MEDV
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 505 42716 85
step(x0.lm, ~ CRIM + ZN + RM)
Start: AIC= 2246.51
MEDV ~ 1
Error in eval(expr, envir, enclos) : Object "MEDV" not found
I am not clear as to why the MEDV object ( the variable I am trying to
predict) is not found. I receive an identical message using the
command > step(x0.lm).