insight icon indicating copy to clipboard operation
insight copied to clipboard

Distribution-level varaince for glmmTMB (family "compois")

Open Pseudachristopher opened this issue 4 months ago • 4 comments

I have run [insight](insight::get_variance) on a fitted glmmTMB model with a "compois" (Conway-Maxwell Poisson) family:

richness_glmmTMB<- glmmTMB(richness ~ vl100m_cs + build50m_cs_o + roads100m_cs + (1 | site/neighbourhood), data = df_Bird, family = "compois", na.action = "na.fail", REML = F) var.distribution is returned as the Dispersion parameter for the Conway-Maxwell (from glmmTMB summary):

Dispersion parameter for compois family (): 0.473

Does this represent an accurate approximation for Distribution-specific variance for a Conway-Maxwell Poisson (compois)? Could Conway-Maxwell be a candidate for additional model support in "insight".

Thank you very much for your time and consideration.

Pseudachristopher avatar Aug 28 '25 02:08 Pseudachristopher

Do you have a reproducible example?

strengejacke avatar Aug 28 '25 23:08 strengejacke

Good evening,

Thank you for taking the time to assist.

I have attached my dataset (wanted to ensure underdispersion and other parameters were maintained over creating an MRE).

Dataset:

CD_df.csv

Code to reproduce:

set.seed(123)

library(glmmTMB)
library(tidyverse)
library(insight)
library(performance)

CD_df <- read.csv("CD_df.csv")

richness_mod <- glmmTMB(richness ~ vl100m_cs + build50m_cs_o + roads100m_cs + (1 | site/neighbourhood), data = df_Bird, family = "compois", na.action = "na.fail", REML = F)

summary(richness_mod)

# Dispersion parameter = 0.473

insight_richness <- insight::get_variance(richness_mod)
insight_richness$var.distribution

# var.distribution - 0.473

I believe performance::r2_nakagawa uses insight::get_variance as an external dependency to derive the metrics needed to calculate Nakagawa's pseudo-R2. I'm by no means qualified to speak much to the intricacies of Conway-Maxwell, but I'm not sure that the dispersion parameter alone is the correct metric to be derived in the case.

Again, I appreciate your time and support. Thank you.

Pseudachristopher avatar Aug 29 '25 00:08 Pseudachristopher

The dispersion parameter is not the variance, rather it is the scaling factor for the conditional variance. The conditional variance is computed as a function of the dispersion parameter and the predicted mean. The total distributional variance is a complex function without a closed form solution. https://en.wikipedia.org/wiki/Conway%E2%80%93Maxwell%E2%80%93Poisson_distribution

bwiernik avatar Aug 29 '25 03:08 bwiernik

Thank you for your time and contribution, Brenton.

This was my understanding, too. Given that the approximation of variance for COMPOIS is complex (albeit possible in some situations, based on my reading of Huang et al 2017), I wonder if the way performance::r2_nakagawa calculates pseudo-R2 (using dispersion factor as distribution variance) leads to biased values. In my case, a value that is surprisingly low.

Again, I appreciate the opportunity to engage with those much more qualified on this topic. Thank you!

Pseudachristopher avatar Aug 29 '25 14:08 Pseudachristopher