statsmodels.stats.inter_rater.krippendorff_alpha_bootstrap#

statsmodels.stats.inter_rater.krippendorff_alpha_bootstrap(data, level='nominal', nboot=1000, alpha=0.05, rng=None)[source]#

Krippendorff’s alpha with a bootstrap confidence interval.

The subjects are resampled with replacement, keeping all ratings of a subject together, and alpha is computed for each sample. The interval is given by the alpha / 2 and 1 - alpha / 2 quantiles of these values.

Added in version 0.16.0.

Parameters:
dataarray_like

Numeric ratings in a 2-D array with subjects in rows and raters in columns, with missing ratings coded as nan, as in krippendorff_alpha.

level{“nominal”, “ordinal”, “interval”, “ratio”}, optional

Level of measurement of the ratings, as in krippendorff_alpha. The default is “nominal”.

nbootint, optional

Number of bootstrap samples. The default is 1000.

alphafloat, optional

Significance level of the confidence interval, which has coverage 1 - alpha. The default 0.05 gives a 95% interval. This is not Krippendorff’s alpha, which is the attribute statistic of the result.

rngint, array_like of int, numpy.random.Generator, or numpy.random.RandomState, optional

Random number generator or seed for the bootstrap samples, passed to statsmodels.tools.rng_qrng.check_random_state. If None, a new generator is seeded from the operating system, so the interval differs between calls.

Returns:
KrippendorffAlphaBootstrapResult

Krippendorff’s alpha, the limits of the confidence interval and the bootstrap values. Unpacks as statistic, ci_low, ci_upp.

See also

krippendorff_alpha

Krippendorff’s alpha without a confidence interval.

Notes

Only the subjects with at least two ratings are resampled, because the others do not enter alpha. The units of the bootstrap are the subjects, so the interval reflects the variation from the sample of subjects for the given raters. This is the interval that Zapf et al. (2016) studied and recommend for Krippendorff’s alpha. In their simulations for nominal data its coverage was close to the nominal level.

Bootstrap samples in which alpha is undefined are left out of the interval; their number is nboot - nboot_valid. If there is no valid sample, or alpha of the data is undefined, the limits are nan.

With few subjects the percentile interval is too narrow, and the values of alpha in the bootstrap samples are discrete. The interval is approximate and depends on the random samples; increase nboot for stable limits.

Hayes and Krippendorff (2007) describe a different bootstrap, which draws from the coincidence matrix instead of the subjects and keeps the expected disagreement fixed. This function does not implement it. In the simulations of Zapf et al. (2016) its coverage was far below the nominal level, which is why they resampled the subjects instead.

References

Zapf, Antonia, Stefanie Castell, Lars Morawietz, and André Karch. 2016. “Measuring Inter-Rater Reliability for Nominal Data – Which Coefficients and Confidence Intervals Are Appropriate?” BMC Medical Research Methodology 16: 93. https://doi.org/10.1186/s12874-016-0200-9

Hayes, Andrew F., and Klaus Krippendorff. 2007. “Answering the Call for a Standard Reliability Measure for Coding Data.” Communication Methods and Measures 1 (1): 77-89. https://doi.org/10.1080/19312450709336664

Examples

The example of Krippendorff (2011), see krippendorff_alpha.

>>> import numpy as np
>>> from statsmodels.stats.inter_rater import krippendorff_alpha_bootstrap
>>> nan = np.nan
>>> data = [[1, 1, nan, 1], [2, 2, 3, 2], [3, 3, 3, 3], [3, 3, 3, 3],
...         [2, 2, 2, 2], [1, 2, 3, 4], [4, 4, 4, 4], [1, 1, 2, 1],
...         [2, 2, 2, 2], [nan, 5, 5, 5], [nan, nan, 1, 1],
...         [nan, 3, nan, nan]]
>>> res = krippendorff_alpha_bootstrap(data, nboot=2000, rng=0)
>>> round(res.statistic, 3)
0.743
>>> res.ci_low < res.statistic < res.ci_upp
True