R/ICC2.lme.R

"ICC2.lme" <-
function (dv, grp, data, weighted=FALSE)
 {
  dv <- data %>% dplyr::select({{dv}}) %>% purrr::reduce(c)
  grp <- data %>% dplyr::select({{grp}}) %>% purrr::reduce(c) %>% factor()
  
  mod <- lme(dv ~ 1, random=~1|grp, na.action=na.omit)
  if (!weighted)
  {icc2 <-  mean(gmeanrel(mod)$MeanRel) }
  else { icc2 <-  weighted.mean(gmeanrel(mod)$MeanRel, gmeanrel(mod)$GrpSize) }
return(icc2)
 
 }

Try the psychometric package in your browser

Any scripts or data that you put into this service are public.

psychometric documentation built on Nov. 6, 2023, 1:06 a.m.