kripp-alpha-demo.R

Uploaded by:fwild

              
library(irr)
iq = rbind( c(1,1,0,1,1,1,1,1,0,1,1,1,0,0,0), c(0,1,0,1,1,1,0,1,1,1,1,1,1,0,0), c(NA,1,NA,NA,0,1,1,1,NA,1,1,1,NA,0,0), c(NA,1,NA,NA,1,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA) )
rownames(iq) = c("obs_01","obs_02","obs_03","obs_04")
t(iq) # to display in your table format

kripp.alpha( iq )

#  Krippendorff's alpha
#
# Subjects = 15 
# Raters = 4 
# alpha = 0.456 

iq2 = iq[1:3,] # take only first three raters, 4th one is too incomplete

incomplete = apply(iq2,2,function(x){any(is.na(x))}) # rows with missing values
iq2 = iq2[,!incomplete] # remove all items with only two ratings

kripp.alpha( iq2  )

# Krippendorff's alpha
# 
# Subjects = 10 
# Raters = 3 
# alpha = 0.665