필터 지우기
필터 지우기

Repeated-measures ANOVA with no between-factor

조회 수: 16 (최근 30일)
Jaimy van den Hout
Jaimy van den Hout 2021년 8월 2일
댓글: Jaimy van den Hout 2021년 8월 2일
Hi all!
I am trying to perform a two-way repeated measures ANOVA by using the function fitrm and ranova. I have two within-factors (e.g. Condition & Side) and no between-subject factors. I tried the code below, based on the different topics on the mathworks help page. Cause I have no between-subjects factor I thought i should use ~1 as constant. However, I keep getting the following error:
Error using RepeatedMeasuresModel.fit (line 1347)
The between-subjects design must have full column rank.
Error in fitrm (line 77)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});
Error in Statistics_JvdH_versie5 (line 7778)
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,'CWSaff-CWS2laff~1','WithinDesign',Condition)
Does anyone know how to solve this problem? Or know another way to perform this analysis in matlab.
See code below:
t_APMoS_MSZP = table(MoS_AP_side1_CWS_MSZP,MoS_AP_side2_CWS_MSZP,MoS_AP_side1_FWS_MSZP,...
MoS_AP_side2_FWS_MSZP,MoS_AP_side1_CWS2_MSZP,MoS_AP_side2_CWS2_MSZP...
,'VariableNames',{'CWSside1','CWSside2','FWSside1','FWSside2','CWS2side1','CWS2side2'});
Condition = table([1 1 2 2 3 3]',[1 2 1 2 1 2]','VariableNames',{'Condition' 'Side'});
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,'CWSside1-CWS2side2~1','WithinDesign',Condition)
[b1_APMoS,A_APMoS,C_APMoS,D_APMoS] = ranova(rm_APMoS_MSZP,'WithinModel','Condition*Side');

답변 (1개)

Scott MacKenzie
Scott MacKenzie 2021년 8월 2일
편집: Scott MacKenzie 2021년 8월 2일
You don't need a between-subjects factor to use ranova. Your design has two within-subjects factors, and that's just fine.
I see two minor issues in your code. First, you've used "Condition" both as the name of the within-subjects design and as the name of one of the variables in the design. Probably not a good idea. Below, I changed the name of the design to withinDesign. Second, you need to define the Condition and Side variables as categorical. I added two lines to do this, and got a clean run of your code with some random test data. See below.
% test data
MoS_AP_side1_CWS_MSZP = rand(20,1);
MoS_AP_side2_CWS_MSZP = rand(20,1);
MoS_AP_side1_FWS_MSZP = rand(20,1);
MoS_AP_side2_FWS_MSZP = rand(20,1);
MoS_AP_side1_CWS2_MSZP = rand(20,1);
MoS_AP_side2_CWS2_MSZP = rand(20,1);
t_APMoS_MSZP = table(MoS_AP_side1_CWS_MSZP,MoS_AP_side2_CWS_MSZP,MoS_AP_side1_FWS_MSZP,...
MoS_AP_side2_FWS_MSZP,MoS_AP_side1_CWS2_MSZP,MoS_AP_side2_CWS2_MSZP...
,'VariableNames',{'CWSside1','CWSside2','FWSside1','FWSside2','CWS2side1','CWS2side2'});
withinDesign = table([1 1 2 2 3 3]',[1 2 1 2 1 2]','VariableNames',{'Condition' 'Side'});
withinDesign.Condition = categorical(withinDesign.Condition);
withinDesign.Side = categorical(withinDesign.Side);
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,'CWSside1-CWS2side2 ~ 1','WithinDesign',withinDesign);
[b1_APMoS,A_APMoS,C_APMoS,D_APMoS] = ranova(rm_APMoS_MSZP,'WithinModel','Condition*Side');
  댓글 수: 1
Jaimy van den Hout
Jaimy van den Hout 2021년 8월 2일
Thanks for your answer. I changed my script according to your suggestions. It did not work at first, but I found out that my data in t_APMoS_MSZP was in the wrong format (due to changes I made earlier ....).
Thanks for the help, it works fine now!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by