Coefficient of Agreement in R

2022年10月7日

The coefficient of agreement, also known as Cohen`s kappa statistic, is a measure of inter-rater reliability, which assesses the consistency between two or more raters in their classification of an attribute or behavior. In statistical analyses, the coefficient of agreement is used to evaluate the agreement or disagreement among raters and to determine the extent of agreement beyond chance.

In R, the coefficient of agreement can be computed using the kappa() function in the ‘irr’ package. The function requires two inputs: the ratings or classifications made by the raters and a summary of the ratings, which is used as a reference or gold standard. The ratings can be in the form of nominal or ordinal variables, or in binary categories such as true/false or present/absent.

To illustrate the use of kappa() function, let`s consider an example in which two doctors rate the severity of a disease on a scale of 1 to 5. The data can be imported into R as a data frame with two columns, one for each rater, and the rows representing the cases or patients. The summary of the ratings can be computed as the mode or median of the ratings across all cases.

# create simulated data

set.seed(123)

rater1 <- sample(1:5, 50, replace = TRUE)

rater2 <- sample(1:5, 50, replace = TRUE)

dat <- data.frame(Rater1 = rater1, Rater2 = rater2)

# compute summary of ratings

summary <- apply(dat, 1, median)

# compute coefficient of agreement

library(irr)

kappa(dat[, 1:2], summary)

The output of the kappa() function shows the coefficient of agreement, which ranges from -1 to 1, with 0 indicating chance agreement and 1 indicating perfect agreement. A coefficient of 0.8 or higher is considered a good level of agreement, while a coefficient below 0.5 suggests poor agreement.

In addition to the kappa() function, R also provides other functions for computing inter-rater reliability, such as alpha(), rho(), and ICC(). These functions differ in their assumptions about the type of data and the level of measurement, and may yield different results depending on the context and purpose of the analysis.

Overall, the coefficient of agreement in R is a useful tool for assessing the reliability and validity of ratings or measurements made by human observers, and for identifying sources of error or bias in the data. As a professional, understanding the coefficient of agreement and its application in R can help you to interpret and explain the results of research studies or data analyses that involve human judgments or observations.

コメント