필터 지우기
필터 지우기

Matlab repeated measures anova - different result than in other packages

조회 수: 7 (최근 30일)
RP
RP 2019년 6월 20일
댓글: Jingwei Sun 2019년 7월 7일
Hello everyone,
I have a problem with repeated measures anovas. Is it possible that Matlab uses a different model unlike other packages and programs? I got a very unlikely result in the anova and then ran it again with SPSS and R which both yielded the same result (and not the same as Matlab). I don't see any mistake in my Matlab code and get no error message, just this really unlikely and apparently wrong result. Has anyone else come across this problem or is there a mistake in my code after all which I just did not spot? Thanks in advance!

답변 (1개)

Jeff Miller
Jeff Miller 2019년 6월 21일
Hi again Rose,
After playing around with this some more, I think the secret is to tell MATLAB that any numerically-coded categories, like this:
% How to reproduce an SPSS mixed ANOVA in MATLAB.
% Here is a toy data set with 6 groups defined by 2 Gender (m/f) x 3 Age (2 people per group).
% Each person is measured 6 times defined by 3 Seasons x 2 Time points.
data = readtable('Sample2x3x3x2.txt'); % File attached
Season = [1,1,2,2,3,3]';
Time = [1,2,1,2,1,2]';
WithinFactors = table(Season,Time);
% CRITICAL: You must indicate that Age, Season, and Time are to be treated
% as categorical indicators rather than as numerical (i.e., regression-type) predictors.
% MATLAB assumes the latter by default.
data.Age = categorical(data.Age);
WithinFactors.Season = categorical(WithinFactors.Season);
WithinFactors.Time = categorical(WithinFactors.Time);
% Run the ANOVA
rm = fitrm(data, 'Seas1Time1-Seas3Time2~Gender*Age','WithinDesign',WithinFactors,'WithinModel','Season*Time');
ranovatable = ranova(rm,'WithinModel','Season*Time');

카테고리

Help CenterFile Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by