Generate a predicted count distribution from a ZINB model of class glmmTMB

心已入冬 提交于 2019-12-24 00:51:31

问题


In a previous question (No zeros predicted from zeroinfl object in R?) there was a great answer explaining why the predicted count distribution from a pscl package ZINB model using the function zeroinfl included so few zeros, and how one would use the different type arguments of the predict.zeroinfl function to generate a predicted count distribution that better reflected the data.

I am running into the same problem, except I am using glmmTMB instead of zeroinfl for a variety of reasons related to model flexibility. The solution to the previous question involved using the argument type = "prob" to estimate the probability of getting a specific value over a range of observed counts. There is no analogous type argument for the predict.glmmTMB function (https://www.rdocumentation.org/packages/glmmTMB/versions/0.2.2.0/topics/predict.glmmTMB). See below for a reproducible example of the problem using glmmTMB. I understand why predictions based on expected value produce so few zeros, but how could I generate a predicted count distribution that more accurately reflects the observed distribution with a model of class glmmTMB?

library(glmmTMB)
data("bioChemists", package = "pscl")
zinb <- glmmTMB(art ~ fem + mar + kid5 + phd + ment, ziformula = ~ ., data = 
bioChemists, family = nbinom2(link = "log"))

table(round(predict(zinb, type="response"))) 
table(bioChemists$art)

Thank you in advance.

来源:https://stackoverflow.com/questions/53599574/generate-a-predicted-count-distribution-from-a-zinb-model-of-class-glmmtmb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!