我需要使用QAIC标准对候选模型进行排名。这就是我尝试过的:
library(MuMIn)
model_global <- glm(vs ~ mpg + disp + wt, family = quasibinomial, mtcars)
model_1 <- glm(vs ~ mpg, family = quasibinomial, mtcars)
model_2 <- glm(vs ~ disp, family = quasibinomial, mtcars)
model_3 <- glm(vs ~ wt, family = quasibinomial, mtcars)
model_null <- glm(vs ~ 1, family = quasibinomial, mtcars)
mod.sel(model_global, model_1, model_2, model_3, model_null, rank="QAIC", chat=deviance(model_global) / df.residual(model_global))
返回此错误:
Error in formula.default(x) : invalid formula
如何使用QAIC对上述模型进行排名?
答案 0 :(得分:3)
您需要将rank.args
作为list
提供(请参阅?model.sel
)
library(MuMIn)
model.sel(model_global, model_1, model_2, model_3, model_null,
rank = QAIC,
rank.args = list(chat = deviance(model_global) / df.residual(model_global)))
在您提供的(不错的小)示例中,chat
恰好是< 1
,生成警告,chat
设置为1。
# Model selection table
# (Intrc) disp mpg wt df logLik QAIC delta weight
# model_global -21.9000 -0.0403 0.6470 5.332 4 -8.844 25.7 0.00 0.569
# model_2 4.1380 -0.0216 2 -11.348 26.7 1.01 0.344
# model_1 -8.8330 0.4304 2 -12.767 29.5 3.85 0.083
# model_3 5.7150 -1.911 2 -15.683 35.4 9.68 0.004
# model_null -0.2513 1 -21.930 45.9 20.17 0.000
# Warning messages:
# 1: In rank(x, chat = 0.631714762477434) :
# 'chat' given is < 1, increased to 1
# ..snip..
答案 1 :(得分:3)
这完全在手册中,所以请先阅读(?model.sel
和?QAIC
)。请注意代码中的两个问题:
QAIC
中model.sel
的参数在rank.args
参数中传递,而非直接传递。?QAIC
和example(QAIC)
中的注意,了解黑客可以解决这个问题。