glmer AICcmodavg 的预测值
predicted values for glmer AICcmodavg
我知道可以使用 AICcmodavg 获得预测值(以原始比例 ~ 概率)和固定效应的 SE,但我正在尝试但没有成功...有人可以帮助我吗?提前致谢
library(lme4)
(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial))
fixef(gm1)
library("AICcmodavg")
predictSE(gm1,
newdata=as.data.frame(period=c("period1","period2","period3","period4")),
type="response",
se.fit=TRUE,
level=0,
print.matrix=F)
最好读 levels(cbpp$period)
,而不是 as.data.frame()
,而是 data.frame()
levels(cbpp$period)
# [1] "1" "2" "3" "4"
predictSE(gm1,
newdata = data.frame(period=c("1", "2", "3", "4")),
type = "response",
se.fit = TRUE,
level = 0,
print.matrix = F)
[已编辑]
查找错误原因的简单方法
fit <- ...(..., data = df)
predictSE(fit, newdata = df)
predictSE(fit, newdata = ...)
# If 1st predictSE() doesn't run, it means the model causes error.
# If 1st runs but 2nd doesn't, it means it is due to newdata.
如果您的模型有两个因素;
newd <- expand.grid(name1 = levels(df$name1), name2 = levels(df$name2))
predictSE(fit, newdata = newd)
# pred <- predictSE(fit, newdata = newd)
# cbind(newd, pred) # help to interpret
我知道可以使用 AICcmodavg 获得预测值(以原始比例 ~ 概率)和固定效应的 SE,但我正在尝试但没有成功...有人可以帮助我吗?提前致谢
library(lme4)
(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial))
fixef(gm1)
library("AICcmodavg")
predictSE(gm1,
newdata=as.data.frame(period=c("period1","period2","period3","period4")),
type="response",
se.fit=TRUE,
level=0,
print.matrix=F)
最好读 levels(cbpp$period)
,而不是 as.data.frame()
,而是 data.frame()
levels(cbpp$period)
# [1] "1" "2" "3" "4"
predictSE(gm1,
newdata = data.frame(period=c("1", "2", "3", "4")),
type = "response",
se.fit = TRUE,
level = 0,
print.matrix = F)
[已编辑]
fit <- ...(..., data = df)
predictSE(fit, newdata = df)
predictSE(fit, newdata = ...)
# If 1st predictSE() doesn't run, it means the model causes error.
# If 1st runs but 2nd doesn't, it means it is due to newdata.
如果您的模型有两个因素;
newd <- expand.grid(name1 = levels(df$name1), name2 = levels(df$name2))
predictSE(fit, newdata = newd)
# pred <- predictSE(fit, newdata = newd)
# cbind(newd, pred) # help to interpret