admin管理员组文章数量:1123768
How do I resolve the error: "Error in family$family : $ operator not defined for this S4 class", when running a zipoisson model in this code? I have tried a poisson model and a quasi poisson model? I believe a 0-inflated Poisson model would better simulate the actual structure of the data, which was skewed by a large number of zeros.
# Fit the GLMM model for zero-inflated Poisson with mean duration
GLMM_freq_dur <- glmmTMB(N.x ~ duration * Sex + (1 | focalID) + (1 | videoID),
data = GLMM_data,
family = poisson (link='log'),zi=~1|focalID,
control = glmmTMBControl(optimizer = "bobyqa", optCtrl =
list(maxfun = 1e6))) # Increase max iterations
# Fit the GLMM model for zero-inflated Poisson with number of action units
GLMM_freq_au <- glmmTMB(N ~ Total_AU * Sex + (1 | focalID) + (1 | videoID),
data = GLMM_data,
family = zipoisson,
control = glmmTMBControl(optimizer = "bobyqa", optCtrl =
list(maxfun = 1e6))) # Increase max iterations
How do I resolve the error: "Error in family$family : $ operator not defined for this S4 class", when running a zipoisson model in this code? I have tried a poisson model and a quasi poisson model? I believe a 0-inflated Poisson model would better simulate the actual structure of the data, which was skewed by a large number of zeros.
# Fit the GLMM model for zero-inflated Poisson with mean duration
GLMM_freq_dur <- glmmTMB(N.x ~ duration * Sex + (1 | focalID) + (1 | videoID),
data = GLMM_data,
family = poisson (link='log'),zi=~1|focalID,
control = glmmTMBControl(optimizer = "bobyqa", optCtrl =
list(maxfun = 1e6))) # Increase max iterations
# Fit the GLMM model for zero-inflated Poisson with number of action units
GLMM_freq_au <- glmmTMB(N ~ Total_AU * Sex + (1 | focalID) + (1 | videoID),
data = GLMM_data,
family = zipoisson,
control = glmmTMBControl(optimizer = "bobyqa", optCtrl =
list(maxfun = 1e6))) # Increase max iterations
Share
Improve this question
edited 14 hours ago
Siddharth Satishchandran
asked yesterday
Siddharth SatishchandranSiddharth Satishchandran
92 bronze badges
3
- 3 There's too much code here to be able to easily identify which part is causing the error, and without any example data we can't run it for ourselves to see when it throws the error. Please see How to write a good R question with a reproducible example. – Eonema Commented yesterday
- Does the glmmTMB package have an example that you can adapt and get the same error? This might shorten the development of an example appropriate to this question. You don’t have a minimal example. – IRTFM Commented yesterday
- Perhaps a duplicate of stackoverflow.com/questions/39727183/… – IRTFM Commented yesterday
1 Answer
Reset to default 0glmmTMB
doesn't have a "zipoisson" family. Instead, you specify a zero-inflated model by specifying the ziformula
argument, e.g.
GLMM_freq_au <- glmmTMB(N ~ Total_AU * Sex + (1 | focalID) + (1 | videoID),
data = GLMM_data,
family = poisson,
ziformula = ~ 1)
if you want to specify a single zero-inflation probability that is constant across all observations, or ziformula ~ .
if you want to include everything that's in the 'main' (conditional) model formula, or something in between, e.g. ziformula ~ Total_AU * Sex
if you wanted to include the fixed effects but not the random effects in the zero-inflation term.
(The error message should be better, though ...)
本文标签:
版权声明:本文标题:r - I get an error when I run my model: "Error in family$family : $ operator not defined for this S4 class" - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736596878a1945161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论