repeated measure anova two options

Hello,
I am trying to use repeated measure ANOVA “ranova” in MATLAB. According to MATLAB tutorial, there are two option: 1: ranova(rm) and 2: ranova(rm,'WithinModel',WM).
I tried both and they give different results for the within model analysis (in my example the within model variable is time; I have repeated measurements). Option 1 has a closer results to those produced by other software like R; however, it does not give me the between model results which are the main effect of between model variables and their interactions. I appreciate it if you let me know what the difference is.
Also, the sums of squares are not the same as what I get from R. Could you please help me find out about this discrepancy?
Best,
Sepideh.

1 Kommentar

Sophi Af
Sophi Af am 15 Dez. 2020
I have included my code here. The data is measurement of mice brain at 8 regions; thus, I am running 8 ranova.
tr=cell(length(tr_p),1);
gr=cell(length(tr_p),1);
for i=1:length(tr_p)
tr{i}=int2str(tr_p(i));
gr{i}=int2str(gr_p(i));
end
for i=1:8
Y1=DaB_a1(:,i);
Y2=DaB_a2(:,i);
Y=[Y1,Y2];
tr_cat=categorical(tr);
gr_cat=categorical(gr);
varnames = {'treatment','disorder','A1','A2'};
t=table(tr_cat,gr_cat,Y1,Y2,'VariableNames',varnames);
% Time=[1 2];
T = table([1 2]','VariableNames',{'Time'});
rm=fitrm(t,'A1-A2 ~ treatment*disorder','WithinDesign', T);
% rm=fitrm(t,'A1-A2 ~ treatment*disorder','WithinModel', Time, 'WithinModel', 'separatemeans');
% [ran0] = ranova(rm);
[ran1] = ranova(rm,'WithinModel','Time');
[ran0] = ranova(rm);
adj1=epsilon(rm);
M1=multcompare(rm, 'Time', 'By', 'treatment');
M2=multcompare(rm, 'Time', 'By', 'disorder');
tr_cat=categorical(tr);
gr_cat=categorical(gr);
intr_cat=tr_cat.*gr_cat;
varnames_cat = {'intr_cat','A1','A2'};
t=table(intr_cat,Y1,Y2,'VariableNames',varnames_cat);
rm=fitrm(t,'A1-A2 ~ intr_cat','WithinModel', Time, 'WithinModel', 'separatemeans');
% [ran2] = ranova(rm);
[ran3] = ranova(rm,'WithinModel','Time');
adj3=epsilon(rm);
M3=multcompare(rm, 'Time', 'By', 'intr_cat');
1;
end

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jeff Miller
Jeff Miller am 15 Dez. 2020

0 Stimmen

Not sure but I think you need
T = table([1 2]','VariableNames',{'Time'});
T.Time = categorical(T.Time); % add this line
Maybe post one of your 't' data tables so the design is clearer?

3 Kommentare

Sophi Af
Sophi Af am 23 Dez. 2020
Hello,
Thank you for your reply. I guess my main issue is the difference between the results of two option: 1: ranova(rm) and 2: ranova(rm,'WithinModel',WM).
I have attached one of my t table data to this email. The data has been recorded in 8 brain areas but I am looking into only the first area now (first data sheet).
I appreciate your help.
Best,
Sepideh.
Jeff Miller
Jeff Miller am 24 Dez. 2020
If each line of your t table represents a different person, then you should use the ranova command including 'WithinModel'.
Sophi Af
Sophi Af am 24 Dez. 2020
Unfortunately, when I use the command including 'WithinModel' the results doesnt make sense including the degrees of freedom. Furthermore, the results are going to be far from what I get from other softwares like R.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 15 Dez. 2020

Kommentiert:

am 24 Dez. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by