dredge function error - R package MuMln

不羁岁月 提交于 2019-12-03 10:02:26

I know this has been solved, however I came across the same issue and think there is a better way.

The issue with using options(na.action = "na.fail") is that it changes the global settings of R. If you have a large script changing the global settings will potentially impact on other sections of your code where you implicitly rely on R's default settings. There are two ways to avoid this:

  1. After using dredge change the settings back via options(na.action = "na.omit").

OR the better way...

  1. Utilise the regression function's ability to "set the argument". In your case:

glm1<-glm(presabs~dca1+dca2+se1+se2, family=binomial(logit), na.action = "na.fail")

EDi

See ?dredge:

# Example from Burnham and Anderson (2002), page 100:
data(Cement)
options(na.action = "na.fail")   #  prevent fitting models to different datasets

fm1 <- lm(y ~ ., data = Cement)
dd <- dredge(fm1)

If you skip the second line, your described error pops up, as the models are fitted to different datasets (due to removal of NAs).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!