eelbrain.pipeline.TwoStageTest

class eelbrain.pipeline.TwoStageTest(stage_1, vars=None, model=None)

Two-stage test: T-test of regression coefficients

Stage 1: fit a regression model to the data for each subject. Stage 2: test coefficients from stage 1 against 0 across subjects.

Parameters:
  • stage_1 (str) – Stage 1 model specification. Coding for categorial predictors uses 0/1 dummy coding.

  • vars (dict) – Add new variables for the stage 1 model. This is useful for specifying coding schemes based on categorial variables. Each entry specifies a variable with the following schema: {name: definition}. definition can be either a string that is evaluated in the events-Dataset, or a (source_name, {value: code})-tuple (see example below). source_name can also be an interaction, in which case cells are joined with spaces ("f1_cell f2_cell").

  • model (str) – This parameter can be supplied to perform stage 1 tests on condition averages. If model is not specified, the stage1 model is fit on single trial data.

Examples

The first example assumes 2 categorical variables present in events, ‘a’ with values ‘a1’ and ‘a2’, and ‘b’ with values ‘b1’ and ‘b2’. These are recoded into 0/1 codes:

TwoStageTest("a_num + b_num + a_num * b_num + index + a_num * index"},
             vars={'a_num': ('a', {'a1': 0, 'a2': 1}),
                   'b_num': ('b', {'b1': 0, 'b2': 1})})

The second test definition uses the “index” variable which is always present and specifies the chronological index of the events as an integer count. This variable can thus be used to test for a linear change over time. Due to the numeric nature of these variables interactions can be computed by multiplication:

TwoStageTest("a_num + index + a_num * index",
             vars={'a_num': ('a', {'a1': 0, 'a2': 1})

Numerical variables can also defined using data-object methods (e.g. Factor.label_length()) or from interactions:

TwoStageTest('wordlength', vars={'wordlength': 'word.label_length()'})
TwoStageTest("ab", vars={'ab': ('a%b', {'a1 b1': 0, 'a1 b2': 1, 'a2 b1': 1, 'a2 b2': 2})})