eval(family$initialize, rho) 错误:拟合 GLMM 时 y 值必须为 0 <= y <= 1
Error in eval(family$initialize, rho) : y values must be 0 <= y <= 1 when fitting a GLMM
尝试拟合 GLMM,该 GLMM 包含对女性和总体的随机效应,并包括测试的固定效应和交互作用:
- 男性和女性的耐热性是否不同?
- 不同地区的果蝇对热冲击的耐受性是否不同?
- 基础和硬化处理是否不同,即是否有适应性?
- 两个地区的驯化效果有区别吗?
- 两性的适应效果是否不同?
- 性别对这两个地区的影响是否不同?
我还需要使用包含在我的代码中的 'individual level random effect':
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
这是我的数据示例 (datatheat):
注意 缩写的列名称(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
谢谢!
?binomial
帮助页面(在 base R 中)解释了如何指定二项式响应。假设你的数据集中的n
列是每次试验的个体数,你要么需要指定'successes'和'failures'的个数作为两列矩阵的列数:
glmer(cbind(Survival, n-Survival) ~ ..., ...)
或指定幸存的比例并给出分母(暴露的总数)作为weights
参数:
glmer(proportion ~ ..., ..., weights = n)
虽然前者在 R 示例中更常见,但我更喜欢后者(但答案应该相同)。
尝试拟合 GLMM,该 GLMM 包含对女性和总体的随机效应,并包括测试的固定效应和交互作用:
- 男性和女性的耐热性是否不同?
- 不同地区的果蝇对热冲击的耐受性是否不同?
- 基础和硬化处理是否不同,即是否有适应性?
- 两个地区的驯化效果有区别吗?
- 两性的适应效果是否不同?
- 性别对这两个地区的影响是否不同?
我还需要使用包含在我的代码中的 'individual level random effect':
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
这是我的数据示例 (datatheat):
注意 缩写的列名称(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
谢谢!
?binomial
帮助页面(在 base R 中)解释了如何指定二项式响应。假设你的数据集中的n
列是每次试验的个体数,你要么需要指定'successes'和'failures'的个数作为两列矩阵的列数:
glmer(cbind(Survival, n-Survival) ~ ..., ...)
或指定幸存的比例并给出分母(暴露的总数)作为weights
参数:
glmer(proportion ~ ..., ..., weights = n)
虽然前者在 R 示例中更常见,但我更喜欢后者(但答案应该相同)。