mixed factor ANOVA in Matlab
Show older comments
Hi
I'm trying to understand how to do a mixed factor ANOVA in Matlab with one within subject factor and one between subject factor. I've been trying to reproduce the analysis performed here: https://www.youtube.com/watch?v=JBoHHFvVsqw which results in a test of the effect of 'Week', 'School' and the interaction between 'Week' and 'School'. I've tried the following code so far but I'm struggling to understand the output which only partly matches the example. The help on ranova doesn't specify what the colon means when listing the terms (seems to be interaction?), and I don't understand why there is no report of the effect of School alone, or if (Intercept):Week is telling me the effect of Week alone. This is the data/code I'm working on:
% define data
dataTable = array2table([3,5,7,0;4,4,8,0;5,3,7,0;3,5,8,0;4,5,7,0;3,5,7,0;1,5,9,1;2,4,8,1;1,3,9,1;1,5,8,1;1,5,7,1;2,4,9,1]);
% convert to table format
dataTable.Properties.VariableNames = {'Week1','Week2','Week3','School'};
% define levels of within subject factor
wsVariable = table([0 1 2]','VariableNames',{'Week'});
% run ANOVA
rm = fitrm(dataTable,'Week1,Week2,Week3~School','WithinDesign',wsVariable)
ranovatbl = ranova(rm)
If there are any Mathworks employees out there, my impression is that the help on using these functions could use a few more simple examples such as this one.
Cheers
Adam
Answers (0)
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!