| Title: | Krippendorff's Alpha for Multi-Valued Data |
|---|---|
| Description: | Calculate Krippendorff's alpha for multi-valued data using the methods introduced by Krippendorff and Craggs (2016) <doi:10.1080/19312458.2016.1228863>. Nominal, ordinal, interval, and ratio data types are supported, with option to create bootstrapped estimates of alpha. |
| Authors: | Corie Drake [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-1517-7103>) |
| Maintainer: | Corie Drake <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.6.0 |
| Built: | 2026-06-18 19:08:34 UTC |
| Source: | https://github.com/eddelbuettel/mvalpha |
These data represent examples found in the original paper describing the calculation of multi-valued Krippendorff's alpha by Krippendorff and Craggs (2016).
ex_table3 ex_table8a ex_table8b ex_table8c ex_table9a ex_table9b ex_table9cex_table3 ex_table8a ex_table8b ex_table8c ex_table9a ex_table9b ex_table9c
Each is a multi-valued nominal set with observers as columns and units as rows.
doi:10.1080/19312458.2016.1228863
Krippendorff K, Craggs R (2016). “The Reliability of Multi-Valued Coding of Data.” Communication Methods and Measures, 10(4), 181–198. doi:10.1080/19312458.2016.1228863.
Generate Multi-Valued Data Sets
generate_mv_data( type = "nominal", n_units = 10, n_observers = 3, n_labels = 5, tpr = 0.8, fpr = 0.01, card_pmf = c(0.3, 0.4, 0.2, 0.1), p_missing = 0 )generate_mv_data( type = "nominal", n_units = 10, n_observers = 3, n_labels = 5, tpr = 0.8, fpr = 0.01, card_pmf = c(0.3, 0.4, 0.2, 0.1), p_missing = 0 )
type |
Data type. One of "nominal", "ordinal", "interval", or "ratio". |
n_units |
Number of units (rows) in data. |
n_observers |
Number of observers (cols) in data. |
n_labels |
Number of possible labels which could be applied to the data. |
tpr |
True Positive Rate. To generate the data, first a latent set of labels. |
fpr |
False Positive Rate. To generate the data, first a latent set of labels. |
card_pmf |
Probability mass function describing the cardinality of observed label sets. Length should be less than or equal to |
p_missing |
Proportion of observations that are randomly missing, indicated by |
A matrix with n_units rows and n_observers columns with list elements.
generate_mv_data()generate_mv_data()
mvalpha() calculates Krippendorff's alpha statistic when multi-valued observers are
allowed to apply multiple values to an observation.
mvalpha(data, type = "nominal", verbose = TRUE, n_boot = NULL, n_threads = 1)mvalpha(data, type = "nominal", verbose = TRUE, n_boot = NULL, n_threads = 1)
data |
a data frame containing a list column for each observer. Each row represents
an observation unit, and each cell contains a vector of 0 to |
type |
a string describing the data type of the label set. This can be "nominal", "ordinal", "interval", or "ratio" and is used to select the appropriate distance metric. |
verbose |
a logical value which toggles whether status updates are printed to the console while alpha is being calculated. |
n_boot |
an integer representing the number of bootstrap estimates to calculate
for mvDo. The default, |
n_threads |
an integer describing the number of cores to allocate to parallelization. |
An object of class mvalpha
Krippendorff K, Craggs R (2016). “The Reliability of Multi-Valued Coding of Data.” Communication Methods and Measures, 10(4), 181–198. doi:10.1080/19312458.2016.1228863.
library(mvalpha) ### replicate example from Table 3 in Krippendoff and Craggs (2016) with bootstrapped estimates # View data ex_table3 # # Estimate alpha # x <- mvalpha(ex_table3, verbose = TRUE, n_boot = 500) # # # View result # x # # # View the unique values observed in the data # x$values # # # View the unique labels used to code the data # x$labels # # # Histogram of bootstrapped estimates # hist(x$bootstrap_mvalpha)library(mvalpha) ### replicate example from Table 3 in Krippendoff and Craggs (2016) with bootstrapped estimates # View data ex_table3 # # Estimate alpha # x <- mvalpha(ex_table3, verbose = TRUE, n_boot = 500) # # # View result # x # # # View the unique values observed in the data # x$values # # # View the unique labels used to code the data # x$labels # # # Histogram of bootstrapped estimates # hist(x$bootstrap_mvalpha)
Wrapper for creating mvalpha class object.
new_mvalpha( mvalpha, type, mvDo, mvDe, bootstrap_mvalpha, unique_cardinalities, units, observers, labels, values, values_by_unit, dist_CK, p_CK, data )new_mvalpha( mvalpha, type, mvDo, mvDe, bootstrap_mvalpha, unique_cardinalities, units, observers, labels, values, values_by_unit, dist_CK, p_CK, data )
mvalpha |
Multi-valued alpha estimate |
type |
a string describing the data type of the label set. This can be "nominal", "ordinal", "interval", or "ratio" and is used to select the appropriate distance metric. |
mvDo |
Observed disagreement |
mvDe |
Expected disagreement |
bootstrap_mvalpha |
Bootstrap estimates of mvalpha |
unique_cardinalities |
Numeric vector of the unique cardinalities observed in the data |
units |
Names of units |
observers |
Names of observers |
labels |
Unique labels used in data |
values |
Unique values used in data |
values_by_unit |
Table of values by unit |
dist_CK |
Distance matrix for label sets C and K |
p_CK |
Probability matrix for label sets C and K |
data |
a data frame containing a list column for each observer. Each row represents
an observation unit, and each cell contains a vector of 0 to |
an mvalpha object
Print generic
## S3 method for class 'mvalpha' print(x, ...)## S3 method for class 'mvalpha' print(x, ...)
x |
mvalpha object |
... |
additional parameters |
invisibly returns the alpha estimate of an mvalpha object
Find the intersection and set difference(s) of two sets all at once and more
efficiently than calling base::intersect() and base::setdiff() separately.
Based on this stackoverflow answer https://stackoverflow.com/a/72631719
set_ops(A, B, type)set_ops(A, B, type)
A, B
|
sets (vectors) of elements |
type |
a string describing the data type of the label set. This can be "nominal", "ordinal", "interval", or "ratio" and is used to select the appropriate distance metric. |