interaction_plot

Produces interaction plots from the specified parameters

2 way interaction plot

Two argumennts are required. The first specifies the dependent variable and the second specifies the variable to use on the x-axis.

This example also specifies that the ‘CONDITION’ factor should be seperated.

Example with a single factor

>>> df=DataFrame()
>>> df.read_tbl('data/words~ageXcondition.csv')
>>> df.interaction_plot('WORDS','AGE',
                        seplines='CONDITION')

produces ‘interaction_plot(WORDS~AGE_X_CONDITION).png’

interaction_plot(WORDS~AGE_X_CONDITION).png

Example with error bars

The yerr keyword controls the errorbars that are placed on the plot. It can be None, a float, ‘ci’, ‘stdev’, or ‘sem’.

‘ci’ => 95% confidence intervals

>>> df=DataFrame()
>>> df.read_tbl('data/words~ageXcondition.csv')
>>> df.interaction_plot('WORDS','AGE',
                        seplines='CONDITION',
                        yerr='ci')

produces ‘interaction_plot(WORDS~AGE_X_CONDITION,yerr=ci).png’

interaction_plot(WORDS~AGE_X_CONDITION,yerr=ci).png

Error bars for repeated-measures experiments

If the data reflect a repeated measures design the error bars found by interaction_plot() will actually be conservative due to the fact they do not take into account within-subject variability. [1], [2] .

In such circumstances the recommended method for constructing interaction plots is to run an analysis of variance using Anova and use Anova. plot(). The Anova class will calculate the appropriate error bars based on the specified main effect or interaction. By default it uses the highest order main-effect/interaction specified by the factors of xaxis, seplines, sepxplots, and sepyplots.

Here is an example of how you would go about doing this.

>>> df=DataFrame()
>>> df.read_tbl('data/words~ageXcondition.csv')
>>> aov = df.anova('WORDS', wfactors=['AGE','CONDITION'])
>>> aov.plot('WORDS','AGE', seplines='CONDITION',
             errorbars='ci', output_dir='output')

produces ‘interaction_plot(WORDS~AGE_X_CONDITION,yerr=0.319836724826).png’

interaction_plot(WORDS~AGE_X_CONDITION,yerr=0.319836724826).png

Example with separate horizontal subplots

>>> df=DataFrame()
>>> df.read_tbl('data\suppression~subjectXgroupXageXcycleXphase.csv')
>>> df.interaction_plot('SUPPRESSION','CYCLE',
                        seplines='AGE',
                        sepxplots='PHASE',
                        yerr='ci')

produces ‘interaction_plot(SUPPRESSION~CYCLE_X_AGE_X_PHASE,yerr=ci).png’

interaction_plot(SUPPRESSION~CYCLE_X_AGE_X_PHASE,yerr=ci).png

Example with separate horizontal and vertical subplots

>>> df=DataFrame()
>>> df.read_tbl('data\suppression~subjectXgroupXageXcycleXphase.csv')
>>> df.interaction_plot('SUPPRESSION','CYCLE',
                        seplines='AGE',
                        sepxplots='GROUP',
                        sepyplots='PHASE',
                        yerr='sem')

produces ‘interaction_plot(SUPPRESSION~CYCLE_X_AGE_X_GROUP_X_PHASE,yerr=sem).png’

interaction_plot(SUPPRESSION~CYCLE_X_AGE_X_GROUP_X_PHASE,yerr=sem).png