1

One of the formula to calculate an intra-class correlation coefficient (ICC) is the following:

enter image description here

I would like to retrieve the value of each component in R in order to calculate the SEM using the following formula

enter image description here

However, the packages that can be used to calculate an ICC don't provide these values in their output. Here's a dataframe to test that out (4 judges, testing the inter-rater reliability):

library(psych)
df<-data.frame("J1"=c(9,6,8,7,10,6),"J2"=c(2,1,4,1,5,2),"J3"=c(5,3,6,2,6,4),"J4"=c(8,2,8,6,9,7))
ICC(df)

#or using irr package
library(irr)
icc(df)

The output from neither of these packages is satisfactory. Any advice?

JKFY13
  • 77
  • 9
  • you can get the variance components from the `lme4` object: `out = ICC(df) ; lme4::VarCorr(out$summary)` – user20650 May 27 '18 at 20:06
  • ... actually help if i read the help page of ?ICC: use `out$lme` – user20650 May 27 '18 at 20:18
  • Thanks. I'm getting an error message, though. Anything missing? – JKFY13 May 27 '18 at 22:41
  • nope. running `library(psych) ; df<-data.frame("J1"=c(9,6,8,7,10,6),"J2"=c(2,1,4,1,5,2),"J3"=c(5,3,6,2,6,4),"J4"=c(8,2,8,6,9,7)) ; out = ICC(df) ; out$lme` gives the variance components – user20650 May 27 '18 at 22:46
  • ... although perhaps you don't have lme4 - it is only [suggested](https://cran.r-project.org/web/packages/psych/index.html). So try installing `lme4`, and then rerunning – user20650 May 27 '18 at 23:05
  • lme4 is installed. I get "NULL" as a result. – JKFY13 May 27 '18 at 23:20
  • okay ; sorry I have nothing else to suggest - the code in my earlier comment works as expected for me. – user20650 May 27 '18 at 23:24
  • Thanks for your help. Actually, when I do `str(out)`I don't see `$lme` in the output. – JKFY13 May 27 '18 at 23:27
  • what does `packageVersion("psych")`. I'm 1.8.3.3. (If you look at `?ICC` you should see under `value`, that `lme` is returned if using the lmer option. As the default is `lmer=TRUE` it should be there – user20650 May 27 '18 at 23:29
  • If you still can't get it , then code it your self `library(lme4) ; m = reshape2::melt(df, variable.name="id") ;m$items = with(m, ave(as.character(id), id, FUN=seq_along)) ;mod <- lmer(value ~ 1 + (1|id) + (1|items), data=m)` - then grab the variance components – user20650 May 27 '18 at 23:34
  • Hey it's working now! I was running an old version of psych. Many thanks, you've made my day :) – JKFY13 May 28 '18 at 01:53
  • great stuff ... please consider writing it up as an answer. – user20650 May 29 '18 at 19:24

0 Answers0