eelbrain.table.repmeas

eelbrain.table.repmeas(y, x, match, sub=None, ds=None)

Create a repeated-measures table

Parameters:
y :

Dependent variable (can be model with several dependents).

x : categorial

Model defining the cells that should be restructured into variables.

match : categorial

Model identifying the source of the measurement across repetitions, i.e. the model that should be retained.

sub :

boolean array specifying which values to include (generate e.g. with ‘sub=T==[1,2]’)

ds : None | Dataset

If a Dataset is specified other arguments can be str instead of data-objects and will be retrieved from ds.

Returns:
rm_table : Dataset

Repeated measures table. Entries for cells of x correspond to the data in y on these levels of x (if cell names are not valid Dataset keys they are modified).

Examples

Generate test data in long format:

>>> ds = Dataset()
>>> ds['y'] = Var([1,2,3,5,6,4])
>>> ds['x'] = Factor('aaabbb')
>>> ds['rm'] = Factor('123231', random=True)
>>> print(ds)
y   x   rm
----------
1   a   1
2   a   2
3   a   3
5   b   2
6   b   3
4   b   1

Compute difference between two conditions:

>>> ds_rm = table.repmeas('y', 'x', 'rm', ds=ds)
>>> print(ds_rm)
rm   a   b
----------
1    1   4
2    2   5
3    3   6
>>> ds_rm['difference'] = ds_rm.eval("b - a")
>>> print(ds_rm)
rm   a   b   difference
-----------------------
1    1   4   3
2    2   5   3
3    3   6   3