two way repeated measures anova

how to do a 2 way repeated measures anova with MATLAB? I need to perform a 2 way anova for a repeated measures data, each having 2 levels. I see anova2 is to be used for between subject designs and anovan when the design is unbalanced. Any advice would be of great help.

4 Comments

Shamini Warda
Shamini Warda on 25 Jul 2020
Edited: Shamini Warda on 25 Jul 2020
Hi. Many thanks for this. this code works fine, but it gives different results. here is how i used it. I have 2 within subject factors, each having two levels.
levels were arranged column wise with 29 observations row wise for each levels
data = [li_l(:,1), li_s(:,1), si_l(:,1), si_s(:,1)];
datatable = array2table(data);
datatable.Properties.VariableNames = {'li_lr','li_sr','si_lr','si_sr'};
WithinFactors = table([1 1 2 2]',[1 2 1 2]','VariableNames',{'Interval','Response'});
rm = fitrm(datatable,'li_lr,li_sr,si_lr,si_sr~1','WithinDesign',WithinFactors);
ranovatable = ranova(rm,'WithinModel','Interval*Response');
any suggestions would be of immense help.
Thank you.
Different results than what?
You probably want to use the 'categorical' command to tell ranova that the numbers in WithinFactors represent arbitrary category labels rather than numerical values of some predictor.
It now works. Thank you very much.

Sign in to comment.

Answers (1)

Scott MacKenzie
Scott MacKenzie on 28 Jul 2021
Visit this question for a simple approach to doing a two-way repeated measures (aka within-subjects) anova using the ranova function.

Products

Release

R2018b

Asked:

on 23 Jul 2020

Answered:

on 28 Jul 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!