Page 1 of 1

Multilevel negative binomial ICC calculation with dummy predictors

Posted: Sun Dec 17, 2023 11:15 am
by ferhattura19
Hi,
I fit a multilevel negative binomial model where level 1 is individuals and level 2 is groups. I have also dummy variables for a couple of categorical variables. I would like to calculate ICC but I am not sure how to do so although I have looked at Leckie et al (2020) and relevant R code provided: https://www.bristol.ac.uk/cmm/media/lec ... ie2020.pdf. (pages 85 and 87, but I am particularly interested in the model in page 87; Table 2: Model 4: Two-level random-intercept negative binomial model). I am not sure because they use this code for the fix part

# Fit model
fm4 <- glmmTMB(y ~ 1 + fsm + (1|school), data = absence, family = nbinom2)
summary(fm4)

# Linear predictor
absence$xb <- predict(fm4)
head(absence)

and I wonder whether I can use a similar code with my all dummy predictors. In other words, is that linear predictor a transformation of the fitted values of my dummy predictors from the model. I have done a bit of reading about this, and I think yes, meaning it does not matter if your predictors are continuous or dummies.

I would appreciate if you could confirm if that's the case or (if not) support me with an example R code.

model <- glmmTMB(count_outcome ~ sex + ethnicity2 + ethnicity3 + ethnicity2 +
age2 + age3 + age4 +
SEC2+ SEC3+ SEC4 +
disability + (1 | group),
data = mydata,
family = nbinom2)
Many thanks,
Ferhat

Re: Multilevel negative binomial ICC calculation with dummy predictors

Posted: Tue Mar 05, 2024 8:01 am
by eremacaw
It looks like you're trying to fit a multilevel negative binomial model with dummy predictors at level 1 (individuals) and a random intercept at level 2 (groups). To calculate the Intraclass Correlation Coefficient (ICC), you'll need to consider both the fixed and random parts of the model.
Here's a modification of your code to include dummy predictors in the fixed part:

# Fit the model
model <- glmmTMB(count_outcome ~ sex + ethnicity2 + ethnicity3 +
age2 + age3 + age4 +
SEC2 + SEC3 + SEC4 +
disability + (1 | group),
data = mydata,
family = nbinom2)

# Get the summary of the model
summary(model)

# Calculate ICC
total_variance <- attr(model, "varcor")$group[1]^2 + attr(model, "sigma")^2
icc <- attr(model, "varcor")$group[1]^2 / total_variance

# Print ICC
cat("Intraclass Correlation Coefficient (ICC):", icc, "\n")