我试图在R中构建一个glmm
,但不断收到错误消息(我是一个完全的初学者)。
我用相机陷阱进行了一个实验,我在其中测试,如果他们对一个目标作出React,我拉在他们前面,所以我的响应变量是二项式。我试图建立一个GLMM,其中所有的变量是固定的因素和天(在其中进行实验是一个随机因素)。谁更有经验告诉我我做错了什么(我第一次尝试只与一个解释变量)?
我尝试了glmm()
和lmer()
:
library(glmm)
set.seed(1234)
ptm <- proc.time()
Detections <- glmm(Detection ~ 0 + Camera, random = list(~ 0 + Day),
varcomps.names = c("Day"), data = data1, family.glmm = bernoulli.glmm,
m = 10^4, debug = TRUE)`
即使使用最小的数据集,它也会产生一个非常大的glmm。
和
library(lme4)
Detections_glmm <- lmer(Detection ~ Camera + (1|Day), family="binomial")
此错误消息如下所示:
Error in lmer(Detection ~ Camera + (1 | Day), family = "binomial") :
unused argument (family = "binomial")
下面是一个最小df:
data.frame(
Detection = c(1, 0, 0, 1, 1, 1, 1, 0, 0, 0),
Temperature = as.factor(c("10","10","10","10","10","20","20",
"0","0","0")),
Distance = as.factor(c("75","75","75","225","225","225",
"75","150","150","150")),
Size = as.factor(c("0","0","0","0","1","1","1","1",
"2","2")),
Light = as.factor(c("1","1","1","1","1","0","0","0",
"0","0")),
Camera = as.factor(c("1","1","2","2","2","3","3","3",
"1","1")),
Day = as.factor(c("1","1","1","2","2","2","3","3",
"3","2"))
以及变量的相关信息:
响应变量:
检测(二项式)
解释变量:
瓶温度:(0、10、20)
与摄像机的距离(75、150、225)
轻度(0/1)
瓶大小(0、1、3)
1条答案
按热度按时间mpbci0fu1#
使用
glmer
应该可以。(lmer
仅适用于线性混合模型,即高斯响应。如果您的数据集中确实只有3天,您可能希望将
Day
视为固定效应而非随机效应,例如,请参见GLMM常见问题解答或this CrossValidated question ...