Skip to content

Instantly share code, notes, and snippets.

@benwhalley
Created June 3, 2016 07:20
Show Gist options
  • Save benwhalley/1297dc3b1d616de41837ca015f338b10 to your computer and use it in GitHub Desktop.
Save benwhalley/1297dc3b1d616de41837ca015f338b10 to your computer and use it in GitHub Desktop.
Function to calculate ICC for lmer model object
# calculate ICC for lmer model object
icc <- function(m){
vc <- as.data.frame((VarCorr(m)))
l <- vc$vcov
data_frame(grp=vc$grp, icc=sapply(l, function(x){x/sum(l)}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment