knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Tidycomm provides the
test_icr() function to conveniently compute intercoder reliability tests for several variables and reliability estimates at the same time.
Test data has to be structured in a long format, with one column indicating the unit (e.g., article 1, article 2, etc.), one column indicating the coder (either by a string or a numeric ID), and one column each per coded variable to test.
For demonstration purposes, we will use the
fbposts data included in Tidycomm that consists of 45 political Facebook posts (identified by
post_id) coded by six coders (identified by
coder_id) for various formal (post type, number of pictures used in post) and populism-related (attacks on elites, references to 'the people', othering) features:
test_icr() computes various intercoder reliability estimates for all specified variables. The first two arguments (in a pipe) are the unit-identifying variable and the coder-identifying variable, followed by the test variables:
fbposts %>% test_icr(post_id, coder_id, pop_elite, pop_people, pop_othering)
If no test variables are specified, all variables in the dataset (excluding the unit and coder variables) will be tested:
fbposts %>% test_icr(post_id, coder_id)
test_icr() supports the following reliability estimates:
agreement: Simple percent agreement.
holsti: Holsti's $CR$ (mean pairwise percent agreement).
kripp_alpha: Krippendorff's $\alpha$.
cohens_kappa: Cohen's $\kappa$ (only available for two coders).
fleiss_kappa: Fleiss' $\kappa$.
brennan_prediger: Brennan & Prediger's $\kappa$ (for more than two coders, von Eye's (2006) proposed extension to multiple coders is computed).
test_icr() will output simple percent agreement, Holsti's $CR$, and Krippendorff's $\alpha$ as reliability estimates. You can add other estimates by setting their name to
TRUE in the function call (and remove the default ones by setting them to
fbposts %>% test_icr(post_id, coder_id, fleiss_kappa = TRUE, agreement = FALSE)
test_icr() assumes all test variables to be nominal. You can set other variable levels by passing a named vector of the form
c(variable_name = "variable_level") to the
fbposts %>% test_icr(post_id, coder_id, levels = c(n_pictures = "ordinal"))
Nominal test variables can be represented by either integer codes or string labels, whereas ordinal variables must be represented by integer codes, and interval/ratio variables must be numeric (integer or float).
Please note that currently only the computation of Krippendorff's $\alpha$ is influenced by the variable level.
Missing values in intercoder reliability tests can be ambiguous (did the coder forget to code this variable for this unit, or does the missing value indicate that none of the categories was deemed fitting?) and present an obstacle to several reliability estimates (of the currently implemented estimates, only Krippendorff's $\alpha$ can deal with missing values).
test_icr() will by default respond with a warning when
NA values are present in the test variables and output
NA for all reliability estimates but Krippendorff's $\alpha$:
# Introduce some missing values fbposts$type <- NA fbposts$type <- NA fbposts$pop_elite <- NA fbposts %>% test_icr(post_id, coder_id)
You can set
na.omit = TRUE to exclude all units with
NA values for a specific test variable from the computation for this variable:
fbposts %>% test_icr(post_id, coder_id, na.omit = TRUE)
There are situations in which all units are coded multiple times, but not by same coders (e.g., in research seminars). Consider the following sample data:
data <- tibble::tibble( unit = c(1, 1, 2, 2, 3, 3), coder = c('a', 'b', 'a', 'c', 'b', 'c'), code = c(1, 0, 1, 1, 0, 0) ) data
Each unit was coded two times, but no coder coded all units. Thus, the units-coders matrix will contain one
NA value per (unit) row, indicating that one coder did not code the respective unit. Setting
na.omit = TRUE in
test_icr() will thus result in an empty units-coders matrix:
data %>% test_icr(unit, coder, code, na.omit = TRUE)
If it is not relevant that all units were coded by same coders, consider setting a variable indicating each coding per unit as the
data %>% dplyr::group_by(unit) %>% dplyr::mutate(coding = 1:dplyr::n()) %>% dplyr::ungroup() %>% test_icr(unit, coding, code)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.