How to extract Lambda and Nu parameters from glmmTMB Conway-Maxwell Poisson regression model

I'm trying to build Conway Maxwell Poisson model with glmmTMB package with model's family = "compois". The model works okay but I cannot find any output from the model that expresses the Conway-Maxwell's Lambda and Nu parameters which hinders me to run Conway-Maxwell random number generator for simulation

Some simple codes to illustrate this

install.packages("COMPoissonReg")
install.packages("glmmTMB")
library(COMPoissonReg)
library(glmmTMB)

#Create artificial COM poisson count data as response variable
data <- data.frame(Response = rcmp(5000, lambda = 3, nu = 2))
#Create artificial poisson count data as explanatory variable
data$Covariate <- rpois(5000, lambda = 1)*data$Response

#Run ConwayMaxwellPois glmmTMB regression model
Mod <- glmmTMB(Response ~ Covariate, 
               family = "compois",
               data = data)
summary(Mod)

#Check Models structure
str(Mod)

#Predict mu
predict(Mod, type = "response")
#Predict dispersion parameters
predict(Mod, type = "disp")

The predict(Mod, type = "response") returns the actual mean which is not the lambda, and the predict(Mod, type = "disp") returns small decimal values which I think those are not the Nu (I've read from some sources that the actual Nu is 1/predict(Mod, type = "disp") but I'm not sure if this is actually true).

Upvotes: 3

Views: 220

Answers (1)

MBrooks
MBrooks

Reputation: 21

1/predict(Mod, type = "disp") is nu. Your simulated data doesn't have nu=2 because this data$Covariate <- rpois(5000, lambda = 1)*data$Response doesn't follow the equation for a GLM with a log-link.

Have you considered using the simulate() function built into glmmTMB? It could simulate from your fitted model. There's an example on page 392 here

Otherwise, eqn 2.2 here in Huang 2017 defines lambda. You can use the uniroot() function to solve the equation for lambda given each value of mu. Sum up to a high value of y, not infinity; then try a higher value of y to confirm that the solution doesn't change. If it changes, then sum up to a higher value of y and try again.

Upvotes: 2

Related Questions