Aggregates a subjects-by-raters matrix of categorical ratings into the subjects-by-categories counts format consumed by [kappa_counts()]: each row is one subject, each column one category, and `out[i, k]` is the number of raters who assigned subject `i` to category `k`. Missing entries (`NA` or, for numeric input, any non-finite value) are simply not counted, so a subject rated by a subset of raters contributes a row whose total is the number of raters who actually scored it.
Aggregating to counts **discards rater identity**, which is exactly the exchangeable-raters representation. Feeding the result to `kappa_counts(estimator = "cat_fiml")` therefore fits the exchangeable count-FIML: the maximum-likelihood estimator one obtains by imposing rater exchangeability on the saturated categorical FIML of `kappa(estimator = "cat_fiml")`. Under genuinely non-exchangeable raters (rater-specific marginals), prefer the rater-identified `kappa(x, estimator = "cat_fiml")` instead, which keeps per-rater information.
Arguments
- x
A subjects-by-raters matrix or data frame of category labels (integer codes, characters, or factors). `NA` — and, for numeric input, any non-finite value — marks a missing rating.
- categories
Optional vector giving the full set of categories and their column order in the output. Defaults to the sorted unique observed labels. Supply it to pin a known category set (including categories that happen to be unobserved, which then appear as all-zero columns) or to control column order. Observed labels outside `categories` are an error.
Value
An integer subjects-by-categories matrix whose columns are named by `categories` and whose row names are carried over from `x`. Suitable as the `x` argument of [kappa_counts()].
See also
[kappa_counts()] for the count-format estimators; [kappa()] for the rater-identified (non-exchangeable) estimators.
Examples
# Gwet (2014): 20 subjects, five raters, categories {0, 1, 2, 3}, with
# missing ratings. Aggregate to counts, then fit the exchangeable
# count-FIML (equivalent to exchangeability-constrained cat_fiml).
counts <- ratings_to_counts(dat.gwet2014)
head(counts)
#> 0 1 2 3
#> [1,] 0 2 2 0
#> [2,] 1 3 0 0
#> [3,] 0 0 1 3
#> [4,] 3 0 0 0
#> [5,] 4 0 0 0
#> [6,] 4 0 0 0
kappa_counts(counts, estimator = "cat_fiml")
#> misskappa: estimator=cat_fiml, weight=nominal
#> estimate se lower upper
#> Fleiss 0.4861 0.1072 0.2760 0.6962
#> Brennan-Prediger 0.5143 0.1067 0.3052 0.7235
# The Fleiss-Cuzick moment estimator is available from the same counts.
kappa_counts(counts, estimator = "fleiss_cuzick")
#> misskappa: estimator=fleiss_cuzick, weight=nominal
#> estimate se lower upper
#> Fleiss 0.4769 0.0942 0.2922 0.6616
#> Brennan-Prediger 0.5004 0.0962 0.3118 0.6890
