Mixed effect models / repeated measures anova



Psychophysiological studies are most often analyzed with a special kind of analysis of variance, that accounts also for within subject changes rather than only for between subject differences. For event-related data, ANSLAB offers the possibility to calculate this kind of analysis directly, without exporting the data to a separate statistic software package. Moreover, you can choose between averaging over time points, or a complete analysis for every time point in your data, allowing to plot statistical parameter curves, for instance p-value for a specific effect over trialtime.


On MS Windows, ANSLAB also offers integration with "R", a powerful open-source calculation platform, that offers more advanced statistics, like MANOVA and Mixed-Effect-Models. You can run these analysis types directly on your psychophysiological data, using an intermediate communication tool (R(D)COM-server). With the help of this server, ANSLAB sends the data to R, has R do the test, and returns the statistical parameters. To run statistical test in this way, "R" and "R(D)COM-server" must be installed on your system.
Both can be downloaded at   http://www.r-project.org/Running an analysis using R then differs from the matlab-based procedure exclusively in the start command: instead of usign the Run M-ANOVA-command from ANSLAB calculate-menu, choose Run R-ANOVA, Run R-LME/NLME or Run R-MANOVA. All other steps, including the definition of the factorial design, loading of required batchfiles and menu settings are identical to the procedure described below.


To run a repeated measures ANOVA, prepare your data as described:

Each condition for every subject has to be saved as an ans average file. Every file has to have the same number of points and number of channels and the same baseline calculation. You need a textfile, listing the paths of those files on your machine (a 'batchfile'), with one path per line.This batchfile has to reflect the design of the planned analysis, that is, your paths have to be listed according to the hierarchy of your factors. The lowest level is always the subject factor, so you 'll start with one cell for which all subjects average files are given. Beneath that, you list all subjects average files for the next cell etc. The subject order has to be identical in every cell, and you have to have equal number of subjects in every cell. Please note that the structure of the batchfile is identical, wether or not you have defined one or more between factor(s)!!!!!

Unequal cell sizes (between) or missing data (within) are not yet supported. Cells are ordered from lowest hierarchy position of the factor to highest hierarchy position. For instance, consider a 2X2X2 design with the factors 'task' (count forward vs count backward), 'color' (count red squares vs. count green squares) and 'gender'. Your batchfile for 16 subjects has to have the following form:




The design string would be the following:

nrofsubjects: 16;
nrofintervalls: 1;
task:2;countforward,countbackward;
color:2;countredsquares,countgreensquares;
between gender:2;male,female;
[0,1,0,1,0,0,1,1,1,1,0,0,1,1,0,0];





Once you've prepared this, load one of the listed files in ANSLAB, set the baseline and display all points. Load the batchfile as filematrix  (File\filematrix\LoadBatchfile). Then choose \Calculate\Repeated Measures Anova\define, and enter your design. You always have to enter the following 2 parts: number of subjects in your sample (ignoring betweenfactors, that is the total number subjects in all groups) and the number of intervalls using the following syntax:

nrofsubjects: number;
nrofintervalls: number;

All other within factor definitions are optional and have to comply with the following syntax:


factorname: numberofgradations ; gradationnames (comma separated);

Between/group factor definitions have the following syntax:


between factorname: numberofgradations ; gradationnames (comma separated);
[ 1 0 1 0 ....]; ( subject vector )

As you can see, one difference to the within factors is the subject vector, which specifies the group affiliation of each subject ( in text-mode, this vector forms a new line right after the factor declaration ). You can supply any integer numbers as group indices, but no strings. These numbers are mapped to the cell names according to their value: the lowest number will be the first group, the next higher number the second group etc. . Subject vectors have to have one element for each subject, but subjects do not have to be grouped according to their group membership (a vector like [0 0 1 1] is equivalent to [0 1 0 1] if your batchfile is ordered accordingly. The second difference to a within factor definition is the mandatory keyword 'between' before the actual factor definition.

If you whish to calculate the design for all points and and view the output as ANS average files, set nrofintervalls to the total number of points in your data files. Please note, that with a high number of timepoints, this analysis can exceed the available RAM of your computer. To effectively avoid the crash, you can reduce the spatial and temporal resolution by using 'Intervall means'.

If you want to run one special analysis for certain time points, enter the number of time intervalls correspondingly. These values have to match the defined segments in ANSLAB (created by mouseclicks, loaded from file, or using the segment-wizard). If more than one interval is provided,  time will be a separat factor in the ANOVA. Please not that for a true pointwise analysis, the whole intervall has to be selected in ANSLAB including baseline points!!!

If you want to use intervalls but still want the output as continuous ANS-files, add the line 'continuous results;' at the end of the design text. The result files will be stepfunctions of time: all timepoints in a defined intervall will have the same value. The automatic creation usually is much easier and sufficient in the case, that you only wish to use intervalls/channelgroups to reduce memory load.

Click 'OK' and choose \Calculate\Repeated Measures Anova\Run Anova or click the 'OK & Run'-button. For a pointwise/continuous analysis, you will be prompted for a target folder, where results are going to be saved. ANSLAB will save one average file in ANS format for every factor and interaction in your ANOVA, containing F- and it's corresponding P-values. For a single analysis,  results will be displayed in a text box in the dialog section, from where you can display means graphically using the 'anova'-tab in the dynamic section of ANSLAB command window.


Moreover, ANSLAB will create a PowerPoint report with data- and statistics-screenshots for every factor and interaction after running the analysis. This requires obviously, that microsoft PowerPoint is installed on your computer.


Post-hoc contrasts (under construction)

Post-Hoc Contrasts usually are calculated for significant effects found in an analysis of variance. In ANSLAB this can be done for one specific analysis of interest. Post-Hocs for one analysis of interest can be calculated from the 'anova'-tab in the dynamic section of ANSLAB command window. It requires that you first selectand plot  the effect that you wish to explore, by adding it's components to the plot. Then you can compare all cells by choosing 'family' from the 'contrast' dropdownmenu (without alpha-error correction). Alternatively, you can enter specific coefficients for your cells by choosing 'custom'-item. Moreover you can calculate a series of contrasts using the Bonferroni-Holm stepdown procedure for alpha-correction by choosing the 'bonf/holm'-item. For this, you need to create a contrast text-file, containing your coefficients for every contrast to calculate with one contrast per line. ANSLAB then calculates these contrasts, sorts them by their significance level, and tells you which ones can be considered significant. Results of all the described tests are appended to the anova results in the listbox of the results window.


[Top]