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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by