repeated measure anova two options

3 vues (au cours des 30 derniers jours)
Sophi Af
Sophi Af le 15 Déc 2020
Commenté : Sophi Af le 24 Déc 2020
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 commentaire
Sophi Af
Sophi Af le 15 Déc 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

Connectez-vous pour commenter.

Réponses (1)

Jeff Miller
Jeff Miller le 15 Déc 2020
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 commentaires
Jeff Miller
Jeff Miller le 24 Déc 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 le 24 Déc 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by