如何从glmer计算LD50?
我正在分析一组数据,其中约有10人接受了一组治疗(时间),并记录了死亡率(活着,死了)<代码>glmer用于数据建模,因为治疗被阻断(试验)。 根据下面的模型,我想预测50%的人死亡的时间如何从glmer计算LD50?,r,lme4,mixed-models,R,Lme4,Mixed Models,我正在分析一组数据,其中约有10人接受了一组治疗(时间),并记录了死亡率(活着,死了)glmer用于数据建模,因为治疗被阻断(试验)。 根据下面的模型,我想预测50%的人死亡的时间 Trial <- c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3) Time <- c(2, 6, 9, 12, 15, 18, 21, 24, 1, 2, 3, 4, 5, 6, 1.5, 3, 4.5, 6, 39) Alive &l
Trial <- c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3)
Time <- c(2, 6, 9, 12, 15, 18, 21, 24, 1, 2, 3, 4, 5, 6, 1.5, 3, 4.5, 6, 39)
Alive <- c(10, 0, 0, 0, 0, 0, 0, 0, 6, 2, 8, 1, 0, 0, 4, 6, 1, 2, 0)
Dead <- c(0, 10, 6, 10, 10, 10, 7, 10, 0, 8, 1, 9, 10, 10, 5, 0, 8, 6, 10)
ostrinaA.glmm<- glmer(cbind(Alive, Dead)~Time+(1|Trial), family = binomial(link="logit"))
summary(ostrinaA.glmm)
我是新的编码,需要帮助调整我的模型的代码。我的尝试如下:
dose.p.glmm <- function(obj, cf = 1:2, p = 0.5) {
eta <- obj$family$linkfun(p)
b <- fixef(obj)[cf]
x.p <- (eta - b[1L])/b[2L]
names(x.p) <- paste("p = ", format(p), ":", sep = "")
pd <- -cbind(1, x.p)/b[2L]
SE <- sqrt(((pd %*% vcov(obj)[cf, cf]) * pd) %*% c(1, 1))
res <- structure(x.p, SE = SE, p = p)
class(res) <- "glm.dose"
res
}
dose.p.glmm <- function(ostrinaA.glmm, cf = 1:2, p = 0.5) {
eta <- ostrinaA.glmm$family$linkfun(p)
b <- fixef(ostrinaA.glmm)[cf]
x.p <- (eta - b[1L])/b[2L]
names(x.p) <- paste("p = ", format(p), ":", sep = "")
pd <- -cbind(1, x.p)/b[2L]
SE <- sqrt(((pd %*% vcov(obj)[cf, cf]) * pd) %*% c(1, 1))
res <- structure(x.p, SE = SE, p = p)
class(res) <- "glm.dose"
res
}
dose.p.glmm(ostrinaA.glmm, cf=1:2, p=0.5)
Error in ostrinaA.glmm$family : $ operator not defined for this S4 class
dose.p.glmm快速看一眼,我想
eta <- obj$family$linkfun(p)
eta是的,非常新的就对了。谢谢你的快速回答,但我仍然有问题。我已经按照您的建议进行了尝试,现在返回错误代码:error:not-implemented-method for cbind2(,)。->>请包作者实现缺少的特性。
f <- family(obj)
eta <- f$linkfun(p)
res <- structure(x.p, SE = matrix(SE), p = p)