尝试拟合一个GLMM,它包含了等效药和种群的随机效应,包括固定的效应和测试的交互作用:
雄性和女性是否有不同的耐热性?来自不同地区的
<编码>H 111这两个区域之间的性别效应不同吗?H 212G 213>
我还需要使用“个人水平随机效应”,它包含在我的代码中:
datheat$replicateID = factor(1:nrow(datheat))
mod = glmer(Survival ~ sex + region + treatment + treatment*region +
treatment*sex + sex*region + (1|isofemale) + (1|population) +
(1|replicateID), data = datheat, family =
binomial)
summary(mod)但是,我一直收到这个错误,我不知道如何修复它:
Error in eval(family$initialize, rho) : y values must be 0 <= y <= 1下面是我的数据示例(datheat):
注意缩写列名(pop=population,iso = isofemale,S*=Survival,X=X..<something>)
region pop treatment iso sex rep n S* X proportion
1 Southwest CAJ hardening D1 Females 1 10 2 20 0.2
2 Southwest CAJ hardening D1 Females 2 10 1 10 0.1
3 Southwest CAJ hardening D1 Females 3 10 5 50 0.5
32 Southwest REG hardening R4 Females 1 10 3 30 0.3
33 Southwest REG hardening R4 Females 2 10 1 10 0.1
34 Southwest REG hardening R4 Females 3 10 3 30 0.3
60 Southwest REG hardening Southwest2 Females 1 10 5 50 0.5
61 Southwest REG hardening Southwest2 Females 2 10 3 30 0.3
62 Southwest REG hardening Southwest2 Females 3 10 0 0 0
74 Southwest PAV hardening Pa1 Females 1 10 2 20 0.2
75 Southwest PAV hardening Pa1 Females 2 10 3 30 0.3
76 Southwest PAV hardening Pa1 Females 3 10 4 40 0.4
136 Southwest CAN hardening C2 Females 1 10 0 0 0
137 Southwest CAN hardening C2 Females 2 10 1 10 0.1
138 Southwest CAN hardening C2 Females 3 10 0 0 0谢谢!
发布于 2021-11-23 02:31:43
?binomial帮助页(以基本R为单位)解释了如何指定二项式响应。假设数据集中的n列是每个试验中的个体数,则需要将“成功”和“失败”的数量指定为两列矩阵的列:
glmer(cbind(Survival, n-Survival) ~ ..., ...)或者指定幸存的比例,并给出分母(暴露的总数)作为weights参数:
glmer(proportion ~ ..., ..., weights = n)虽然前者在R示例中比较常见,但我更喜欢后者(但答案应该是相同的)。
https://stackoverflow.com/questions/70074129
复制相似问题