{
  "name": "Columns produced by model.matrix formulas on the R documentation example data frame",
  "description": "Number of design-matrix columns for formulas applied to the data frame dd (a = gl(3,4), b = gl(4,1,12)) from the R model.matrix help page, derived from the documented rules: levels minus one contrasts per factor under default coding, plus an intercept, interactions as products of main-effect columns, and the intercept removed by 0 or -1.",
  "page": "https://casrai.org/guides/model-matrix-in-r",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-18T05:50:47Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Formula",
      "unit": "",
      "description": ""
    },
    {
      "name": "Number of columns",
      "unit": "columns",
      "description": ""
    },
    {
      "name": "Basis",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Formula": "~ a",
      "Number of columns": 3,
      "Basis": "Intercept plus 2 contrasts for a (3 levels)"
    },
    {
      "Formula": "~ a + b",
      "Number of columns": 6,
      "Basis": "Intercept plus 2 for a plus 3 for b"
    },
    {
      "Formula": "~ a * b",
      "Number of columns": 12,
      "Basis": "a + b + a:b: 1 + 2 + 3 + 6 interaction columns"
    },
    {
      "Formula": "~ 0 + a",
      "Number of columns": 3,
      "Basis": "Intercept removed with 0, a coded with one column per level"
    }
  ],
  "sources": [
    {
      "title": "R documentation: model.matrix",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/stats/html/model.matrix.html",
      "accessed": "2026-11-18"
    },
    {
      "title": "R documentation: contrasts",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/stats/html/contrasts.html",
      "accessed": "2026-11-18"
    },
    {
      "title": "R documentation: formula",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html",
      "accessed": "2026-11-18"
    }
  ]
}