Why does the number of rows change during AIC in R? How to ensure that this doesn't happen?

前端 未结 3 1863
春和景丽
春和景丽 2021-01-12 09:27

I\'m trying to find a minimal adequate model using AIC in R. I keep getting the following error: Error in step(model) : number of rows in use has changed: remove mi

3条回答
  •  旧时难觅i
    2021-01-12 09:53

    I was faced with the same problem but I couldn't use Flodel's solution because I couldn't access the original data because it was computed inside a function. I give here my alternative solution which only uses the model. Let data be the dataset with missing values:

    model1<-lm(response~., data=data)
    model2<-lm(response~., data=model1$model)
    step(model2)
    

    Although this way wastes some computer time, it has the advantage of just using information already contained in the model.

提交回复
热议问题