Kappa | R Documentation |
Kappa() computes de Cohen's kappa coefficient for nominal or ordinal data. If data is ordinal, weigthed kappa can be applied to allow disagreements to be weighted differently.
Kappa( m, r = 0, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, partial = FALSE )
m |
a squared matrix of frequencies between two observers. |
r |
an integer (0, 1, or 2) to create a matrix of weigths. See details. |
alternative |
a string specifying the alternative hypothesis to construct the confidence interval: either "two.sided" (default), "greater" or "less". |
conf.level |
confidence level of the interval. |
partial |
a logical value indicating whether to evaluate the degree of agreement of each category by collapsing the contingency table. |
The weighted kappa can be computed when data are ordinal and the argument r
is eigher 1 or 2:
if r = 0, unweighted kappa is computed (used for nominal variables)
if r = 1, weighted kappa with linear formula is applied
if r = 2, weighted kappa with quadratic formula is applied
A list of 3 elements containing the kappa statistic, the standard error and the confidence interval.
If "partial = TRUE"
, a data.frame containing 3 columns (the class, the unweighted partial kappa coefficient
for each class and the standards error of each estimate) is added to the list.
# Create a 3x3 matrix m = matrix(c(15, 5, 0, 4, 21, 1, 3, 4, 25), ncol = 3) # Compute the Kapa coefficient for nominal data Kappa(m, r = 0, partial = TRUE) # Compute the Kapa coefficient for ordinal data, using linear formula Kappa(m, r = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.