Discrepancy in repeated measures ANOVA using anovan. Full model VS Terms matrix
1 view (last 30 days)
Show older comments
I have found that the results in a repeated measures anova, using anovan, are different if I used 'full' model or if I specificy a matrix terms that test for main effects plus interactions. Can someone explain the difference? Example below:
Example No.1
My data consists of G, groups with A animals (different animals per group). In each animal, X values are measured from D locations.
Example No.1
Repeated measures ANOVA using A as random factor nested to group:
[p tbl stats terms] = anovan(X, {G D A}, 'random', 3,...
'nested', [0, 0, 0 ; 0 0 0 ;1 0 0 ],...
'varnames', {'group','depth','animal'},'model','full');
The results show a significant effect of group, depth and the interaction between them (p=0.0151, 4.44e-157 and 0.0385, respectively).
However when I explicitly indicate a term matrix the results are different:
Example No. 2
testterms= [1 0 0; % to test effect of group
0 1 0; % to test effect of depth
1 1 0]; % to test interaction group-depth
[p tbl stats terms] = anovan(X, {G D A}, 'random', 3,...
'nested', [0, 0, 0 ; 0 0 0 ;1 0 0 ],...
'varnames', {'group','depth','animal'},'model',testterms);
The results show a very significant effect of group and depth but no interaction (p= 5.39e-13, 6.1425e-125 and p=0.8049, respectively).
Why this differences? Additionally, if I run a two-way ANOVA it gives me the exact same values as in Example No.2.
[tp tt p terms] = anovan(X,{G D}, 'model','full','varnames',{'group','depth'});
Why does it occur? Why when I input the testterms matrix it seems like suddenly it is not longer a repeated measurements ANOVA?
To complicate things I run a linear effects-mixed model as a way to get a similar result as the repeated measurements anova using a nested anovan. I follow the same method as in here: https://www.mathworks.com/matlabcentral/answers/247286-discrepancy-between-anova-and-fitlme
if true %ignore this line
tbl= table(G',D', A',X', 'variablenames',{'group','depth', 'animal','X'});
tbl.group = nominal(tbl.group);
tbl.animal = nominal(tbl.animal);
lme_general = fitlme(tbl,' X~ group*depth +(1 |animal:group) ','FitMethod','reml');
anova_lme_general=anova(lme_general, 'dfmethod','satterthwaite');
end %ignore this line
This give only a significant effect of depth but a strong interaction (p=2.18 e-73 and 5.21e-7, respectively)
Can someone please explain the differences between example 1 and example 2? Why Example 2 seems to be equivalent to a two-way anova that has no repeated measurements and nested animal? Which of the two examples would fit better to my data? Thanks
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!