[R-sig-ME] Zero-truncated Poisson distribution in glmmTMB
Erik Solbu
er|k@@o|bu @end|ng |rom n|b|o@no
Sat Apr 25 09:24:37 CEST 2020
Hi everyone,
I'm trying to replace a package called 'poilog' with glmmTMB, but the results differ in such a way that I'm not sure how to interpret the results from glmmTMB. I've written a short example below:
#### Start of code ####
# Required packages
library(poilog)
library(glmmTMB)
# Simulate using the 'poilog' package
# sim_01 <- rpoilog(S = 1000, mu = 0, sig = 2, keep0 = TRUE)
# This is the same as
sim_01 <- rpois(n = 1000, lambda = exp(rnorm(n = 1000, mean = 0, sd = 2)))
# estimate the parameters
# using the 'poilog' package, assume regular Poisson distribution
est_01 <- poilogMLE(n = sim_01, zTrunc = FALSE)
# using the 'poilog' package, assume zero truncated Poisson distribution
est_02 <- poilogMLE(n = sim_01[sim_01>0], zTrunc = TRUE)
# make data.frame for glmmTMB estimation
df_01 <- data.frame(abundance = sim_01,
species = 1:length(sim_01))
# using the 'glmmTMB' package, assume regular Poisson distribution
est_03 <- glmmTMB(abundance ~ (1 | species),
family = poisson(link = "log"),
data = df_01)
# using the 'glmmTMB' package, assume zero truncated Poisson distribution
est_04 <- glmmTMB(abundance ~ (1 | species),
family = truncated_poisson(link = "log"),
data = df_01[df_01$abundance>0, ])
# Compare estimates
est_df <- data.frame(method = rep(c("poilog", "glmmmTMB"), each = 2),
assumptions = rep(c("poisson", "truncated_poisson"), 2),
mu = c(est_01$par[1], est_02$par[1],
est_03$fit$par[1], est_04$fit$par[1]),
sigma = c(est_01$par[2], est_02$par[2],
exp(c(est_03$fit$par[2], est_04$fit$par[2]))))
est_df
#### End of code ####
When I fit the truncated_poisson model in glmmTMB, the mean increases and the standard deviation decreases, which is similar to what happens if you ignore the zeros and fit a regular poisson distribution, but it doesn't seem to be doing quite that either.
So, I'm hoping anyone knew how to interpret the mean and standard deviation from the truncated_poisson output and how they relate to the mean and standard deviation of a regular poisson model?
Thank you very much for reading this and any response is much appreciated.
Best regards,
Erik
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list