4
$\begingroup$

I have a negative binomial mixed model with counties nested within states. I've read that the formula for the ICC for a negative binomial model is:

enter image description here
found here: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3916583/

When I run VarCorr(m10), on my random intercept model, I get:
Groups Name Std.Dev. state (Intercept) 0.22709

Could someone explain how to extract the other information from my glmer() model so that I can write a function to compute the ICC? e.g., fixef(m10) gets me the intercept term.

$\endgroup$
1
  • $\begingroup$ It seems that in your model you did not estimate several of the terms that are referenced in the ICC equation. The equation refers to several different variance components but you only have a single random intercept term. $\endgroup$ Commented Sep 1, 2015 at 21:48

1 Answer 1

2
$\begingroup$

This is my functional code (using glmer.nb()):

ICC.NB <- function(model){
  sigma_a2 <- as.numeric(exp(data.frame(VarCorr(model))["vcov"]))
  beta <- as.numeric(fixef(model)["(Intercept)"])
  r <- getME(model,"glmer.nb.theta")
  icc <- (exp(sigma_a2) - 1) / ((exp(sigma_a2) - 1) + ((exp(sigma_a2) - 1) / r) + (exp(-beta - (sigma_a2 / 2))))
  icc
}
ICC.NB(model = m12)
$\endgroup$
7
  • 1
    $\begingroup$ I think there are some ways to make this less fragile and more readable, e.g. use ["vcov"] in place of [4] in the sigma extraction; use "(Intercept)" instead of [1] to get the intercept; use getME(model,"glmer.nb.theta")) instead of the big ugly gsub call ... $\endgroup$
    – Ben Bolker
    Commented Sep 1, 2015 at 20:55
  • $\begingroup$ @BenBolker , I edited the post and implemented your suggested changes. Thank you. $\endgroup$ Commented Sep 1, 2015 at 21:03
  • 1
    $\begingroup$ don't forget to test them ... :-) $\endgroup$
    – Ben Bolker
    Commented Sep 1, 2015 at 21:09
  • 1
    $\begingroup$ PS I think the as.numeric()s are unnecessary? $\endgroup$
    – Ben Bolker
    Commented Sep 1, 2015 at 21:10
  • $\begingroup$ Good idea. Now, I'm trying to add a "var" parameter to make it work with a three level model by setting what the sigma should be. $\endgroup$ Commented Sep 1, 2015 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.