eelbrain.test.anova

eelbrain.test.anova(y, x, sub=None, ds=None, title=None, caption=None)

Univariate ANOVA

Mixed effects models require balanced models and full model specification so that E(MS) can be estimated according to Hopkins (1976).

Parameters:
y : Var

dependent variable

x : Model

Model to fit to y

sub : index

Only use part of the data.

ds : Dataset

Dataset to use data from.

title : str | FMText

Title for the results table.

caption : str | FMText

Caption for the results table.

Returns:
table : FMText Table

Table with results.

Examples

Simple n-way between subjects ANOVA:

>>> ds = datasets.get_uv(nrm=True)
>>> print(test.anova('fltvar', 'A*B', ds=ds))
                SS   df      MS          F        p
---------------------------------------------------
A            28.69    1   28.69   25.69***   < .001
B             0.04    1    0.04    0.03        .855
A x B         1.16    1    1.16    1.04        .310
Residuals    84.85   76    1.12
---------------------------------------------------
Total       114.74   79

For repeated measures designs, whether a factors is fixed or random is determined based on the Factor.random attribute, which is usually specified at creation:

>>> ds['rm'].random
True

Thus, with rm providing the measurement unit (subject for a within-subject design), the A*B model can be fitted as repeated measures design:

>>> print(test.anova('fltvar', 'A*B*rm', ds=ds))
            SS   df      MS   MS(denom)   df(denom)          F        p
-----------------------------------------------------------------------
A        28.69    1   28.69        1.21          19   23.67***   < .001
B         0.04    1    0.04        1.15          19    0.03        .859
A x B     1.16    1    1.16        1.01          19    1.15        .297
-----------------------------------------------------------------------
Total   114.74   79

Nested effects are specified with parentheses. For example, if each condition of B was run with separate subjects (in other words, B is a between-subjects factor), subject is nested in B, which is specified as subject(B):

>>> print(test.anova('fltvar', 'A * B * nrm(B)', ds=ds))
            SS   df      MS   MS(denom)   df(denom)          F        p
-----------------------------------------------------------------------
A        28.69    1   28.69        1.11          38   25.80***   < .001
B         0.04    1    0.04        1.12          38    0.03        .856
A x B     1.16    1    1.16        1.11          38    1.05        .313
-----------------------------------------------------------------------
Total   114.74   79

Numerical variables can be coerced to categorial factors in the model:

>>> ds = datasets.get_loftus_masson_1994()
>>> print=(test.anova('n_recalled', 'exposure.as_factor()*subject', ds=ds))
            SS       df   MS         F         p
---------------------------------------------------
exposure     52.27    2   26.13   42.51***   < .001
---------------------------------------------------
Total      1005.87   29