# What is the proper ANOVA to run for repeated-measures data cross multiple experimental groups?

I am having trouble knowing:

(1) The proper statistical test to run on my data, and (2) The proper way to run this test in Matlab.

I have 2 experimental groups: a control and a treatment group. Each group is tested over multiple weeks (we have 1 measurement/week).

This google doc has an example simulated dataset and an example plot.

Originally, I thought the proper test to do was a "two-way repeated measure ANOVA", and I attempted to run it like so in Matlab:

t = table(groups, data(:, 2), data(:, 3), data(:, 4), ...
data(:, 5), data(:, 6), ...
'VariableNames', {'Group', 'Wk1', 'Wk2', 'Wk3', 'Wk4', 'Wk5', 'Wk6'});
timepoints = [2 3 4 5 6 7];
rm = fitrm(t, 'Wk1-Wk6~Group', 'WithinDesign', timepoints);
my_ranova_results = ranova(rm);


It gave me results like the following:

                    SumSq    DF    MeanSq      F         pValue      pValueGG    pValueHF    pValueLB
______   __    ______    ______    __________    ________    ________    ________
(Intercept):Time    4978.3     7    711.18     5.388    5.7155e-05    0.02521     0.020408    0.042684
Group:Time          2658.7     7    379.82    2.8775      0.010625    0.10041     0.093003     0.12068
Error(Time)         9239.5    70    131.99


However, I then read the "Mixed-design analysis of variance" article on Wikipedia, where it states: "In statistics, a mixed-design analysis of variance model (also known as a split-plot ANOVA) is used to test for differences between two or more independent groups whilst subjecting participants to repeated measures." Should I be using a two-way mixed-model ANOVA?

To do so in Matlab, I fit the data into a table with the columns "Group", "Timepoint", and "Score". I then ran the following code:

lin_model_formula = 'Score ~ Group + (1|Timepoint)';
lin_model = fitlme(scores_table, lin_model_formula);
my_anova_results = anova(lin_model);


When doing so, it gave me the following results:

ANOVA marginal tests: DFMethod = 'Residual'

Term                 FStat     DF1    DF2    pValue
'(Intercept)'        891.51    1      82     8.0667e-46
'Group'              62.397    1      82     1.1061e-11


Notice 2 things: - There is no interaction effect reported - The degrees of freedom are different

So, to finish up: what is the proper test to run in this situation? And, finally, have I written my Matlab "formula" correctly in each case? Matlab's documentation on writing these formulas is very hard to understand.

• Your first repeated measures analysis is a mixed model. The variable "subjects" is implicitly included in your analysis and is a random effect. Also, the assumption of sphericity is rarely met and when violated, the Type I error rate is inflated. One option is to use the multivariate approach the other is the epsilon correction. I am not familiar with Matlab. – David Lane Jan 24 '17 at 2:14