bsmschema.models.Contrast#

object Contrast#

Contrasts are weighted sums of parameter estimates (betas) generated by a model fit.

Contrast defines the structure of the elements of the Node.Contrasts list.

Along with DummyContrasts, Contrasts define the outputs of a Node.

While "t" and "pass" contrasts are passed as inputs to the next node, "F" contrasts are terminal and are not passed as inputs to following Nodes.

Examples

Subtract two conditions:

{
  "Name": "a_vs_b",
  "ConditionList": ["A", "B"],
  "Weights": [1, -1],
  "Test": "t"
}

Contrast one condition to the average of two others:

{
  "Name": "a_vs_other",
  "ConditionList": ["A", "B", "C"],
  "Weights": [1, -0.5, -0.5],
  "Test": "t"
}

To pass an individual parameter estimate without changing its name to following nodes:

{"Name": "A", "ConditionList": ["A"], "Weights": [1], "Test": "t"}
Config:
  • extra: str = forbid

field Name: str [Required]#

The name of the contrast. Must be unique in Node.Contrasts and must not appear in DummyContrasts.Contrasts for the same Node.

This name will be attached to output statistical maps via the "contrast" entity.

field ConditionList: List[Literal[1] | str] [Required]#

A list of variables used to compute the contrast. Must be a subset of the variables listed in Model.X.

The special intercept value 1 is permitted.

field Weights: List[int | float | str] | List[List[int | float | str]] [Required]#

A 1D or 2D array of weights. The array must have exactly the same number of total elements as in ConditionList. For t-tests, a 1D array must be passed. For F-tests, either a 1D or a 2D array may be passed. Variables are mapped 1-to-1 onto weights in the order they appear in ConditionList. Fractional values MAY be passed as strings (e.g., “1/3”).

field Test: Literal['pass', 't', 'F'] [Required]#

The type of test statistic to compute on the contrast. The special value "pass" indicates that no statistical test is to be performed.

Note that "F" contrasts are terminal and not passed as inputs to following Nodes.