repeated measure anova two options

4 ビュー (過去 30 日間)
Sophi Af
Sophi Af 2020 年 12 月 15 日
コメント済み: Sophi Af 2020 年 12 月 24 日
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 件のコメント
Sophi Af
Sophi Af 2020 年 12 月 15 日
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

サインインしてコメントする。

回答 (1 件)

Jeff Miller
Jeff Miller 2020 年 12 月 15 日
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 件のコメント
Jeff Miller
Jeff Miller 2020 年 12 月 24 日
If each line of your t table represents a different person, then you should use the ranova command including 'WithinModel'.
Sophi Af
Sophi Af 2020 年 12 月 24 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by