Reputation: 11
This is my first consult, happy to share the community :) (You would notice I'm not a native english speaker and also I'm not very good using R, actually these are my firsts steps).
I'm trying to conduct a regression (stepwise). I have one continuous dependent variable (General assessment of seminar quality) and I'm trying to know how well other questions I asked my students (quality of the materials, the level of participation, etc.) predict a good global assessment.
All variables are continuous (1-7)
Here is the code:
Regressió_Total_Forward <- lm(Val_general ~ Val_tema+Val_material+Val_interacció+Val_participa+Val_oral+Val_feina+Val_fatiga+Val_temps_pràctica+Val_ajust_temps, data=Sem_1)
step(Regressió_Total_Forward,direction="backward")
And R returns this:
Error in step(Regressió_Total_Forward, diretion = "backward") : AIC is -infinity for this model, so 'step' cannot proceed
What should I do??
Thank you <3
If I try to do a "forward" or "both" regression, the same error appears.
Upvotes: 1
Views: 34
Reputation: 132969
I can reproduce the issue like this:
DF <- data.frame(x1 = 1, x2 = 1, y = 1)
fit <- lm(y ~ x1 + x2, data =DF)
step(fit, diretion = "backward")
#Error in step(fit, diretion = "backward") :
# AIC is -infinity for this model, so 'step' cannot proceed
An AIC of -Inf
can only happen with a log-likelihood of Inf
, which means a perfect fit. However, due to floating-point inaccuracies, you usually don't get that but get instead just a large negative AIC. step
then gives a warning "attempting model selection on an essentially perfect fit is nonsense"
. The error only seems to occur if lm
returns some NA
coefficients. You should check your predictors for collinearity.
Upvotes: 1