cohensKappa: Cohen's kappa coefficient

Description Usage Arguments Details Value Note Examples

View source: R/cohensKappa.R

Description

Calculates Cohen's κ (kappa) coefficient for two equal length vectors.

Usage

1
cohensKappa(x, y, adjusted = TRUE)

Arguments

x

vector, coerced to factor.

y

vector, coerced to factor.

adjusted

logical. If adjusted=FALSE, the unadjusted accuracy is returned instead.

Details

Cohen's kappa coefficient measures the agreement between two categorical vectors. Zero indicates that the agreement is no better than expected by chance, while a value of one indicates perfect correspondence.

Value

If adjusted=TRUE, returns the kappa coefficient [-1,1]. If adjusted=FALSE, returns ordinary accuracy [0,1].

Note

Cases with NA in either input vector are ignored.

Examples

1
2
3
4
x <- crcTCGAsubset$CMS
cohensKappa(x, x) # equals 1
replicate(10, cohensKappa(x, sample(x))) # expectation = 0
replicate(10, cohensKappa(x, sample(x), adjusted=FALSE)) # expectation > 0

peterawe/CMScaller documentation built on June 13, 2020, 4:49 a.m.