In my dataset, I have 5 readers who have classified tests (as either 0, 1 or 2) repeatedly over multiple days.
On each day, only 2-3 readers out of the 5 actually classified tests.
library(tidyverse)
library(broom)
df <- tibble(day = rep(1:10,10)) %>%
arrange(day) %>%
mutate(reader1 = rep(c(1, 2, 0, 0, 2, NA, NA, NA, NA, NA), each = 2, 5),
reader2 = rep(c(NA, NA, NA, NA, NA, 1, 1 , 0, 1, 2), each = 2, 5),
reader3 = rep(c(1, 1, 1, 0, 2, NA, NA, NA, NA, NA), each = 2, 5),
reader4 = rep(c(NA, NA, NA, NA, NA, 2, 1, 0, 1, 2), each = 2, 5),
reader5 = rep(c(NA, NA, NA, NA, NA, 2, 2, 0, 1, 2), each = 2, 5))
Ultimate aim is to estimate intraclass correlations (using the ICC command in the psych package) between readers at each day. Ideal output would be a single data frame with the ICCs (and 95% confidence intervals) for each day to allow plotting.
This answer has been helpful, but only applies to situations with exactly two readers.
Where I am stuck:
Firstly, for each day, dropping columns where readers did not classify test (I think this is needed as ICC cannot have readers with no observations).
df %>%
group_by(day) %>%
nest()
#something here to drop non-readers
select_if(colSums(!is.na(.)) > 0)
#doesn't work. Need to slice into separate data frames?
Secondly, how to extract ICCs and 95% CIs into a single tidy data frame?
df %>%
group_by(day) %>%
nest() %>%
#something here to split data by day
do(ICC(.)) %>%
tidy()
#not working