InteractionTerm

A two-way parametric interaction between two bare covariates, e.g. x1 * x2.

Usage

Source

InteractionTerm(
    left,
    right,
    full=True,
)

Represents a crossing of two columns in the model matrix (numeric-by-numeric products, numeric-by-factor varying slopes, or factor-by-factor cell means, depending on the column types). Use this when you want an interaction without smoothing — for a smooth interaction surface between two continuous covariates, use a tensor-product SmoothTerm (te(), ti(), or t2()) instead, or a factor-by SmoothTerm for “one smooth per group”.

full=True corresponds to *-style crossing (R’s convention): both main effects (x1 and x2 individually) plus the interaction column(s) are included. full=False corresponds to :-style crossing: the interaction only, with no accompanying main effects. Note that the parser (whittaker.formula.parser.parse) currently only produces terms with full=True (x1 * x2 syntax); x1:x2 colon syntax is not valid Python and is rejected at parse time, so full=False terms must be constructed directly if needed.

Parameters

left: str

Name of the first covariate.

right: str

Name of the second covariate.

full: bool = True
If True (default), include both main effects and the interaction (*-style). If False, include only the interaction, dropping the main effects (:-style).