← All procedures

statistics.bootstrapClusters

A cluster bootstrap: each run draws whole clusters with replacement, and the statistic reads the rows of the drawn clusters. Use it when the rows of one cluster (one board, one seed, one site) are not independent. The clusters are in the order of their first row.

CLI
Package
@procedures/statistics · README
Path
["statistics","bootstrapClusters"]
CLI
mark statistics bootstrapClusters --rows <any[]> --cluster <object> --statistic <object>
As data
{"$proc":["statistics","bootstrapClusters"],"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","bootstrapClusters"], { rows: [], cluster: {}, statistic: {} });
console.log(JSON.stringify(result));

From the command line

$ mark statistics bootstrapClusters --rows <any[]> --cluster <object> --statistic <object>

As data, in a program

{
  "$proc": ["statistics", "bootstrapClusters"],
  "input": { "rows": [], "cluster": {}, "statistic": {} }
}

Input

FieldTypeRequiredDefaultDescription
rowsany[]yes
clusterobjectyesOne call of a pure procedure, as data, for the function (row: T) => string. It reads each parameter as {"$ref": "<name>"}: row.
statisticobjectyesOne call of a pure procedure, as data, for the function (rows: readonly T[]) => number. It reads each parameter as {"$ref": "<name>"}: rows.
optionsobjectno

Output

FieldTypeRequiredDefaultDescription
estimatenumberyesThe statistic of all the data.
lownumberyes
highnumberyes
levelnumberyes
runsnumberyes
finitenumberyesThe number of runs whose statistic is a finite number. Only these runs make the interval.
seednumberyesThe seed as a 32-bit number.
againstnumbernoThe value of the option `against`.
pAbovenumbernoThe p of the claim "the statistic is above `against`": (1 + the finite runs at or below `against`) / (finite + 1).
pBelownumbernoThe p of the claim "the statistic is below `against`": (1 + the finite runs at or above `against`) / (finite + 1).
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "rows": {
        "type": "array",
        "items": {}
      },
      "cluster": {
        "type": "object",
        "properties": {
          "$proc": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "input": {},
          "$when": {
            "type": "string",
            "const": "$never"
          }
        },
        "required": [
          "$proc"
        ],
        "additionalProperties": {},
        "x-procedures-program": {
          "params": [
            "row"
          ],
          "inputs": [
            {}
          ],
          "output": {
            "type": "string"
          }
        },
        "description": "One call of a pure procedure, as data, for the function (row: T) => string. It reads each parameter as {\"$ref\": \"<name>\"}: row."
      },
      "statistic": {
        "type": "object",
        "properties": {
          "$proc": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "input": {},
          "$when": {
            "type": "string",
            "const": "$never"
          }
        },
        "required": [
          "$proc"
        ],
        "additionalProperties": {},
        "x-procedures-program": {
          "params": [
            "rows"
          ],
          "inputs": [
            {
              "type": "array",
              "items": {}
            }
          ],
          "output": {
            "type": "number"
          }
        },
        "description": "One call of a pure procedure, as data, for the function (rows: readonly T[]) => number. It reads each parameter as {\"$ref\": \"<name>\"}: rows."
      },
      "options": {
        "type": "object",
        "properties": {
          "runs": {
            "type": "number",
            "description": "The number of samples. The default is 10 000."
          },
          "level": {
            "type": "number",
            "description": "The level of the interval. The default is 0.95."
          },
          "seed": {
            "description": "The seed of the draws. The default is 1.",
            "type": [
              "string",
              "number"
            ]
          },
          "method": {
            "type": "string",
            "enum": [
              "higher",
              "linear",
              "nearest-rank"
            ],
            "description": "The quantile method of the two ends of the interval. The default is linear."
          },
          "ends": {
            "type": "array",
            "items": [
              {
                "type": "number"
              },
              {
                "type": "number"
              }
            ],
            "additionalItems": {},
            "minItems": 2,
            "maxItems": 2,
            "description": "The quantiles of the two ends, in place of `level`, for example [0.025, 0.975] or an interval with one side. The default is from the level: (1 - level) / 2 and 1 - (1 - level) / 2. In floating point, (1 - 0.95) / 2 is not 0.025, so a copy that writes 0.025 needs this option to give the same numbers."
          },
          "against": {
            "type": "number",
            "description": "The value of a claim to test, for example 0 for \"no difference\". With this option, the interval also gives `pAbove` and `pBelow` from the same draws, so the ends do not change. The default is no value and no p."
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "rows",
      "cluster",
      "statistic"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "estimate": {
        "type": "number",
        "description": "The statistic of all the data."
      },
      "low": {
        "type": "number"
      },
      "high": {
        "type": "number"
      },
      "level": {
        "type": "number"
      },
      "runs": {
        "type": "number"
      },
      "finite": {
        "type": "number",
        "description": "The number of runs whose statistic is a finite number. Only these runs make the interval."
      },
      "seed": {
        "type": "number",
        "description": "The seed as a 32-bit number."
      },
      "against": {
        "type": "number",
        "description": "The value of the option `against`."
      },
      "pAbove": {
        "type": "number",
        "description": "The p of the claim \"the statistic is above `against`\": (1 + the finite runs at or below `against`) / (finite + 1)."
      },
      "pBelow": {
        "type": "number",
        "description": "The p of the claim \"the statistic is below `against`\": (1 + the finite runs at or above `against`) / (finite + 1)."
      }
    },
    "required": [
      "estimate",
      "low",
      "high",
      "level",
      "runs",
      "finite",
      "seed"
    ],
    "additionalProperties": {}
  }
}