title: How to calculate the Intraclass correlation (ICC) in R?
body: <p>I have a dataset that is in a long format with 200 variables, 94 subjects, and each subject has anywhere from 1 to 3 measurements for each variable.</p>
  <p>Eg:</p>
  <pre><code>ID measurement var1 var2 . . .
  1  1           2    6
  1  2           3    8 
  1  3           6    12
  2  1           3    9
  2  2           4    4
  2  3           5    3 
  3  1           1    11
  3  2           1    4
  .  .           .    .
  .  .           .    .
  .  .           .    . 
  </code></pre>
  <p>However, some variables have missing values for one of three measurements. It was suggested to me that before imputing missing values with the mean for the subject, I should use a repeated measures ANOVA or mixed model in order to confirm the repeatability of measurements.</p>
  <p>The first thing I found to calculate the ICC was the ICC() function from the psych package. However, from what I can tell this requires that the data have one row per subject and one column per measurement, which would be further complicated by the fact that I have 200 variables I need to calculate the ICC for individually. I did go ahead and calculate the ICC for a single variable, and obtained this output:</p>
  <pre><code>Intraclass correlation coefficients 
                           type  ICC   F df1 df2             p lower bound upper bound
  Single_raters_absolute   ICC1 0.38 2.8  93 188 0.00000000067        0.27        0.49
  Single_random_raters     ICC2 0.38 2.8  93 186 0.00000000068        0.27        0.49
  Single_fixed_raters      ICC3 0.38 2.8  93 186 0.00000000068        0.27        0.49
  Average_raters_absolute ICC1k 0.65 2.8  93 188 0.00000000067        0.53        0.74
  Average_random_raters   ICC2k 0.65 2.8  93 186 0.00000000068        0.53        0.74
  Average_fixed_raters    ICC3k 0.65 2.8  93 186 0.00000000068        0.53        0.74
  
   Number of subjects = 94     Number of Judges =  3
  </code></pre>
  <p>Next, I tried to calculate the ICC using a mixed model. Using this code:</p>
  <pre><code>m1 &lt;- lme(var1 ~ measurement, random=~1|ID, data=mydata, na.action=na.omit)
  summary(m1)
  </code></pre>
  <p>The output looks like this:</p>
  <pre><code>Linear mixed-effects model fit by REML
   Data: mydata
          AIC       BIC   logLik
    -1917.113 -1902.948 962.5564
  
  Random effects:
   Formula: ~1 | ORIGINAL_ID
          (Intercept)    Residual
  StdDev: 0.003568426 0.004550419
  
  Fixed effects: var1 ~ measurement
                            Value    Std.Error  DF  t-value p-value
  (Intercept)         0.003998953 0.0008388997 162 4.766902  0.0000
  measurement         0.000473053 0.0003593452 162 1.316429  0.1899
   Correlation: 
                      (Intr)
  measurement         -0.83 
  
  Standardized Within-Group Residuals:
          Min          Q1         Med          Q3         Max 
  -3.35050264 -0.30417725 -0.03383329  0.25106803 12.15267443 
  
  Number of Observations: 257
  Number of Groups: 94 
  </code></pre>
  <p>Is this the correct model to use to assess ICC? It is not clear to me what the correlation (Intr) is measuring, and it is different from the ICC obtained using ICC().</p>
  <p>This is my first time calculating and using intraclass correlation, so any help is appreciated!</p>