eelbrain.table.repmeas
- eelbrain.table.repmeas(y, x, match, sub=None, data=None)
Create a repeated-measures table
- Parameters
y (Union[NDVar, str, Model, Var, Factor, Interaction, NestedEffect]) – Dependent variable (can be model with several dependents).
x (Union[Factor, Interaction, NestedEffect, str]) – 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 (Union[Var, ndarray, str]) – boolean array specifying which values to include (generate e.g. with ‘sub=T==[1,2]’)
data (Dataset) – If a Dataset is specified other arguments can be str instead of data-objects and will be retrieved from ds.
- Returns
rm_table – Repeated measures table. Entries for cells of
x
correspond to the data iny
on these levels ofx
(if cell names are not valid Dataset keys they are modified).- Return type
Examples
Generate test data in long format:
>>> ds = Dataset() >>> data['y'] = Var([1,2,3,5,6,4]) >>> data['x'] = Factor('aaabbb') >>> data['rm'] = Factor('123231', random=True) >>> print(data) 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', data=data) >>> 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