非常感谢任何帮助,在此先感谢。
我使用包中的model.avg()
函数对三个 GLMM 模型进行了平均MuMIn
。我现在想从这个平均模型中进行预测。但是,当我调用predict()
R 时似乎认为我想要predict.merMod()
并因此引发警告消息,因为我要求提供标准错误,而predict.merMod()
. 相反,我想调用predict.averaging()
哪个是对类模型的适当调用,averaging
并将为模型预测提供标准错误。predict.averaging()
如果我尝试通过指定来强制使用 R,MuMIn::predict()
或者MuMIn::predict.averaging()
我收到一条错误消息,指出该函数不是从MuMIn
.
任何帮助解决这个问题将不胜感激?我想从 class 的平均模型中进行预测averaging
,并希望获得估计值和标准误差。
下面的可重现示例。
# Load packages
> library(MuMIn); library(lme4)
# Create test data set
> test <- rbind(mtcars, mtcars)
> test <- rbind(mtcars, test)
# Create test models
> t1 <- glmer(am ~ hp + (1 | carb), data = test, family = binomial)
> t2 <- glmer(am ~ hp + vs + (1 | carb), data = test, family = binomial)
# Create model list and average models
> list <- list(t1, t2)
> p1 <- model.avg(list)
# Create new data set for predictions
> nd <- mtcars[1:2,]
> nd <- select(nd, hp, vs)
# Model predictions demonstrating errors and warnings
> predict(p1, backtransform = TRUE, newdata = nd, re.form = NA, se.fit = TRUE)
Mazda RX4 Mazda RX4 Wag
0.8938837 0.8938837
Warning messages:
1: In predict.merMod(object = new("glmerMod", resp = new("glmResp", :
unused arguments ignored
2: In predict.merMod(object = new("glmerMod", resp = new("glmResp", :
unused arguments ignored
> MuMIn::predict(p1, backtransform = TRUE, newdata = nd, re.form = NA, se.fit = TRUE)
Error: 'predict' is not an exported object from 'namespace:MuMIn'
> predict.averaging(p1, backtransform = TRUE, newdata = nd, re.form = NA, se.fit = TRUE)
Error in predict.averaging(p1, backtransform = TRUE, newdata = nd, re.form = NA, :
could not find function "predict.averaging"
> MuMIn::predict.averaging(p1, backtransform = TRUE, newdata = nd, re.form = NA, se.fit = TRUE)
Error: 'predict.averaging' is not an exported object from 'namespace:MuMIn'
> MuMIn:::predict.averaging(p1, backtransform = TRUE, newdata = nd, re.form = NA, se.fit = TRUE)
Mazda RX4 Mazda RX4 Wag
0.8938837 0.8938837
Warning messages:
1: In predict.merMod(object = new("glmerMod", resp = new("glmResp", :
unused arguments ignored
2: In predict.merMod(object = new("glmerMod", resp = new("glmResp", :
unused arguments ignored