[R-sig-ME] negative binomial ICC for the GLMM

Birnbaum, Lisa ||@@@b|rnb@um @end|ng |rom |@u@de
Wed Jan 23 08:27:32 CET 2019


Dear Timothy,

I wanna calculate a negative binomial ICC for the null model with Rdistanc as depedent variable and schoolid as cluster variable. In the last step I get an error message. I am not sure if I did it right with the numerator. Can you please help me?

This is my R-code:

#Specify the model first

  model = glmer.nb(formula = Rdistanc ~ 1 + (1 | schoolid), data = dat)

 # Then execute this code for ICC calculation for negative binomial.
  #There is nothing you need to change to the code, it's a function independent of the data.
  #################################
  ICC.NB <- function(model, numerator){
    require(lme4)
    mout <- data.frame(VarCorr(model)) # random intercept model variances
    sigma_a2 <- sum(mout[mout$grp %in% numerator, "vcov"]) # random effect(s) in numerator

    sigma_2 <- sum(mout["vcov"]) # sum of random effects variance in denominator
    beta <- as.numeric(fixef(model)["(Intercept)"]) # fixed effect intercept
    r <- getME(object = model, "glmer.nb.theta") # theta
    icc <- (exp(sigma_a2) - 1) / ((exp(sigma_2) - 1) + (exp(sigma_2) /
                                                          r) + (exp(-beta) - (sigma_2 / 2)))
    return(icc)
  }
  ##################################
  # Lastly, run
  ICC.NB (glmer.nb(formula = dat$Rdistanc ~ 1 + (1 | dat$schoolid), data = dat, numerator = dat$schoolid))

I really would appreciate your help.
Best regards,
Lisa

--
Lisa Birnbaum, M.A.
Friedrich-Alexander-Universit�t Erlangen-N�rnberg
Lehrstuhl f�r Empirische Bildungsforschung
Regensburger Str. 160
90478 N�rnberg
Mail: lisa.birnbaum using fau.de


	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list