Skip to contents

Computes Cohen's kappa, PABAK, Gwet's AC1, positive and negative agreement, Byrt prevalence and bias indices, and two confidence intervals for kappa (Wald, and a logit-transformed Wilson-type interval).

Usage

grass_compute(
  data,
  format = c("wide", "matrix", "long", "paired"),
  positive = NULL,
  ...
)

Arguments

data

Input data. Form depends on format:

  • "matrix" – a 2x2 integer count matrix with R1 rows, R2 columns.

  • "wide" – a data.frame with exactly two rater columns (or pass rater_cols = c("r1", "r2") if the data contains extra columns).

  • "long" – a data.frame with subject, rater, and rating columns (names configurable via subject =, rater =, rating =). Must contain exactly two distinct raters.

  • "paired" – a list of two equal-length rating vectors, a 2-column matrix, or a 2-column data.frame.

format

One of "matrix", "wide", "long", "paired".

positive

Optional character string naming the level to treat as the positive (=1) class. Defaults to "yes" if present among levels, then "1" / "true" / "positive" / "case", then first-encountered.

...

Format-specific arguments: rater_cols for "wide"; subject, rater, rating for "long".

Value

A grass_metrics S3 object.

Deprecated

grass_compute() is deprecated in grass 0.2.0. The new headline API is grass_report(ratings = Y) returning a grass_card object. The full coefficient panel is available via summary() or as.data.frame(). See vignette("reporting-card") and grass_report().

Examples

# 2x2 counts (Cohen 1960 Table 1)
tab <- matrix(c(88, 10, 14, 88), nrow = 2,
              dimnames = list(R1 = c("0", "1"), R2 = c("0", "1")))
grass_compute(tab, format = "matrix")
#> `grass_compute()` is deprecated in grass 0.2.0. The new headline API is `grass_report(ratings = Y)`. See `vignette('reporting-card')` and `?grass_report`.
#> grass metrics (N = 200; positive level = '1')
#>   2x2 table
#>    R2
#> R1   0  1
#>   0 88 14
#>   1 10 88
#> 
#>   Observed agreement P0  : 0.8800
#>   Expected agreement Pe  : 0.4998
#>   Cohen's kappa          : 0.7601   Wald 95% CI [0.6216, 0.8986]
#>   PABAK                  : 0.7600
#>   Gwet's AC1             : 0.7600
#>   Positive agreement     : 0.8800
#>   Negative agreement     : 0.8800
#>   Prevalence index (PI)  : 0.0000
#>   Bias index (BI)        : 0.0200

# Paired vectors
r1 <- c(1, 1, 0, 0, 1, 0, 1)
r2 <- c(1, 0, 0, 0, 1, 1, 1)
grass_compute(list(r1, r2), format = "paired")
#> Warning: Small sample (N = 7). Inference based on GRASS simulations is unreliable below N = 10.
#> grass metrics (N = 7; positive level = '1')
#>   2x2 table
#>    R2
#> R1  0 1
#>   0 2 1
#>   1 1 3
#> 
#>   Observed agreement P0  : 0.7143
#>   Expected agreement Pe  : 0.5102
#>   Cohen's kappa          : 0.4167   Wald 95% CI [-0.3241, 1.1575]
#>   PABAK                  : 0.4286
#>   Gwet's AC1             : 0.4400
#>   Positive agreement     : 0.7500
#>   Negative agreement     : 0.6667
#>   Prevalence index (PI)  : 0.1429
#>   Bias index (BI)        : 0.0000