Anova

car::Anova()-style ANOVA table for a fitted linear mixed model. Produces per-term F- or chi-square statistics with Satterthwaite denominator degrees of freedom. Mirrors the interface of car::Anova() in R.

Anova(model, type='III', test='F')[source]

car::Anova()-style ANOVA table for a fitted LMM.

Parameters:
  • model – A fitted CrossedLMEResult, or a list of two such results for likelihood-ratio test (LRT) comparison. When a list is supplied, type and test are ignored and the LRT table from interlace.anova() is returned.

  • type – ANOVA type: 'II' or 'III' (default). Ignored when model is a list.

  • test – Test statistic: 'F' (default) or 'Chisq'. 'F' returns the same table as anova_type2() / anova_type3(). 'Chisq' converts to Wald chi-square statistics (Chisq = F * df1) and reports chi-square p-values. Ignored when model is a list.

Return type:

Any

Returns:

pandas.DataFrame – For test='F': columns ["term", "df1", "df2", "F", "Pr(>F)"]. For test='Chisq': columns ["term", "df", "Chisq", "Pr(>Chisq)"]. For a list of models: LRT table from interlace.anova().

Raises:

ValueError – If type is not 'II' or 'III', test is not 'F' or 'Chisq', or if a list of REML-fitted models is passed.

Parameters:
  • model (Any)

  • type (str)

  • test (str)

Returned columns

test='F' (default)

Column

Description

term

Fixed-effect term name

df1

Numerator degrees of freedom (number of columns for this term)

df2

Satterthwaite denominator degrees of freedom

F

Wald F-statistic

Pr(>F)

p-value from the F distribution

test='Chisq'

Column

Description

term

Fixed-effect term name

df

Degrees of freedom (df1)

Chisq

Wald chi-square statistic (F * df1)

Pr(>Chisq)

p-value from the chi-square distribution

Choosing between Type II and Type III

Type

Use when

type='III' (default)

Interpreting main effects in the presence of interactions; matches lmerTest::anova() Type III output

type='II'

Additive models (no interactions), or when you want hierarchical marginal tests; requires ML refit internally

For additive models (no interactions) the two types produce identical results because the hypothesis matrices coincide. The distinction matters only when interactions are present.

Examples

Basic Type III F-table

import interlace

result = interlace.fit("rt ~ condition + load", data=df, groups=["subject", "item"])

tbl = interlace.Anova(result)
print(tbl)
#        term  df1       df2      F   Pr(>F)
# 0  condition    1   38.2   31.2   0.0000
# 1       load    1   41.5    8.9   0.0048

Type II

tbl2 = interlace.Anova(result, type="II")

Chi-square statistics

tbl_chisq = interlace.Anova(result, test="Chisq")
#        term  df  Chisq  Pr(>Chisq)
# 0  condition   1   31.2      0.0000
# 1       load   1    8.9      0.0028

LRT comparison (two-model form)

When a list of two models is passed, Anova() delegates to the LRT-based anova function (both models must use method="ML"):

m0 = interlace.fit("rt ~ 1",         data=df, groups=["subject", "item"], method="ML")
m1 = interlace.fit("rt ~ condition", data=df, groups=["subject", "item"], method="ML")

interlace.Anova([m0, m1])   # LRT table, same as interlace.anova(m0, m1)

See also

  • anova — likelihood-ratio test for two nested models

  • emmeans — marginal means and contrasts after fitting

  • fit — fitting the model