← All procedures

statistics.cohenKappa

Cohen's kappa of two raters (Cohen, 1960). Item `i` has the category `a[i]` from one rater and `b[i]` from the other. Two categories are the same when they are `===`. A kappa of 1 is full agreement, and 0 is the agreement of chance.

CLI
Package
@procedures/statistics · README
Path
["statistics","cohenKappa"]
CLI
mark statistics cohenKappa --a <any[]> --b <any[]>
As data
{"$proc":["statistics","cohenKappa"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/statistics/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["statistics","cohenKappa"], { a: [], b: [] });
console.log(JSON.stringify(result));

From the command line

$ mark statistics cohenKappa --a <any[]> --b <any[]>

As data, in a program

{ "$proc": ["statistics", "cohenKappa"], "input": { "a": [], "b": [] } }

Input

FieldTypeRequiredDefaultDescription
aany[]yes
bany[]yes

Output

FieldTypeRequiredDefaultDescription
nnumberyesThe number of items.
observednumberyesThe part of the items where the two raters give the same category.
chancenumberyesThe part of agreement that two independent raters with the same frequencies of categories give.
kappanumbernoCohen's kappa: `(observed − chance) / (1 − chance)`. It is `undefined` when `chance` is 1.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "a": {
        "type": "array",
        "items": {}
      },
      "b": {
        "type": "array",
        "items": {}
      }
    },
    "required": [
      "a",
      "b"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number",
        "description": "The number of items."
      },
      "observed": {
        "type": "number",
        "description": "The part of the items where the two raters give the same category."
      },
      "chance": {
        "type": "number",
        "description": "The part of agreement that two independent raters with the same frequencies of categories give."
      },
      "kappa": {
        "type": "number",
        "description": "Cohen's kappa: `(observed − chance) / (1 − chance)`. It is `undefined` when `chance` is 1."
      }
    },
    "required": [
      "n",
      "observed",
      "chance"
    ],
    "additionalProperties": {}
  }
}