{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/crosstabs-com/json-schema/crosstabs-com-contingency-response-schema.json",
  "title": "ContingencyResponse",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/crosstabs-com-openapi.json#/components/schemas/ContingencyResponse",
  "type": "object",
  "properties": {
    "input": {
      "$ref": "#/$defs/Input"
    },
    "docs": {
      "type": "string",
      "const": "https://www.crosstabs.com/developers"
    },
    "chiSquare": {
      "type": "object",
      "properties": {
        "chiSquare": {
          "type": "number"
        },
        "degreesOfFreedom": {
          "type": "integer"
        },
        "pValue": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "required": [
        "chiSquare",
        "degreesOfFreedom",
        "pValue"
      ]
    },
    "chiSquareYates": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "chiSquare": {
              "type": "number"
            },
            "degreesOfFreedom": {
              "type": "integer"
            },
            "pValue": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          },
          "required": [
            "chiSquare",
            "degreesOfFreedom",
            "pValue"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "gTest": {
      "type": "object",
      "properties": {
        "gStatistic": {
          "type": "number"
        },
        "degreesOfFreedom": {
          "type": "integer"
        },
        "pValue": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "required": [
        "gStatistic",
        "degreesOfFreedom",
        "pValue"
      ]
    },
    "fishersExact": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "pValue": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "oddsRatio": {
              "type": [
                "number",
                "null"
              ]
            },
            "oddsRatioState": {
              "type": "string",
              "enum": [
                "finite",
                "positive_infinity"
              ]
            },
            "oddsRatioCI": {
              "type": "array",
              "items": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "minItems": 2,
              "maxItems": 2
            },
            "oddsRatioCIStates": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "finite",
                  "positive_infinity"
                ]
              },
              "minItems": 2,
              "maxItems": 2
            }
          },
          "required": [
            "pValue",
            "oddsRatio",
            "oddsRatioState",
            "oddsRatioCI",
            "oddsRatioCIStates"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "fishersExactUnavailableReason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null,
        "not_2x2",
        "invalid_counts",
        "unsafe_integer_counts",
        "non_positive_margins",
        "workload_limit",
        "disabled_by_caller"
      ]
    },
    "cramersV": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number"
        },
        "label": {
          "type": "string",
          "enum": [
            "negligible",
            "small",
            "medium",
            "large"
          ]
        }
      },
      "required": [
        "value",
        "label"
      ]
    },
    "phi": {
      "type": [
        "number",
        "null"
      ]
    },
    "contingencyCoefficient": {
      "type": "number"
    },
    "lambda": {
      "type": "object",
      "properties": {
        "symmetric": {
          "type": "number"
        },
        "rowDependent": {
          "type": "number"
        },
        "colDependent": {
          "type": "number"
        }
      },
      "required": [
        "symmetric",
        "rowDependent",
        "colDependent"
      ]
    },
    "gamma": {
      "type": "number"
    },
    "kendallTau": {
      "type": "object",
      "properties": {
        "tauB": {
          "type": "number"
        },
        "tauC": {
          "type": "number"
        }
      },
      "required": [
        "tauB",
        "tauC"
      ]
    },
    "somersD": {
      "type": "object",
      "properties": {
        "symmetric": {
          "type": "number"
        },
        "rowDependent": {
          "type": "number"
        },
        "colDependent": {
          "type": "number"
        }
      },
      "required": [
        "symmetric",
        "rowDependent",
        "colDependent"
      ]
    },
    "theilsU": {
      "type": "object",
      "properties": {
        "symmetric": {
          "type": "number"
        },
        "rowGivenCol": {
          "type": "number"
        },
        "colGivenRow": {
          "type": "number"
        }
      },
      "required": [
        "symmetric",
        "rowGivenCol",
        "colGivenRow"
      ]
    },
    "expected": {
      "type": "object",
      "properties": {
        "counts": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "number"
            }
          }
        },
        "min": {
          "type": "number"
        },
        "cellsBelow5": {
          "type": "integer"
        }
      },
      "required": [
        "counts",
        "min",
        "cellsBelow5"
      ]
    },
    "totals": {
      "type": "object",
      "properties": {
        "row": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "col": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "row",
        "col"
      ]
    }
  },
  "required": [
    "input",
    "docs",
    "chiSquare",
    "chiSquareYates",
    "gTest",
    "fishersExact",
    "fishersExactUnavailableReason",
    "cramersV",
    "phi",
    "contingencyCoefficient",
    "lambda",
    "gamma",
    "kendallTau",
    "somersD",
    "theilsU",
    "expected",
    "totals"
  ],
  "$defs": {
    "FrequencyMatrix": {
      "type": "array",
      "minItems": 2,
      "maxItems": 12,
      "items": {
        "type": "array",
        "minItems": 2,
        "maxItems": 12,
        "items": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000000
        }
      },
      "description": "Additional runtime constraints: rectangular rows; grand total ≤ 1000000000000; every row and column sum must be positive. Ordinary JSON Schema cannot enforce these cross-cell sums.",
      "x-grand-total-maximum": 1000000000000
    },
    "Input": {
      "type": "object",
      "properties": {
        "table": {
          "$ref": "#/$defs/FrequencyMatrix"
        },
        "n": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000000000
        },
        "rows": {
          "type": "integer",
          "minimum": 2,
          "maximum": 12
        },
        "cols": {
          "type": "integer",
          "minimum": 2,
          "maximum": 12
        }
      },
      "required": [
        "table",
        "n",
        "rows",
        "cols"
      ]
    }
  }
}