# Matlab repeated measures anova - different result than in other packages

13 visualizaciones (últimos 30 días)
RP el 20 de Jun. de 2019
Comentada: Jingwei Sun el 7 de Jul. de 2019
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!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Jeff Miller el 21 de Jun. de 2019
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');
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Jingwei Sun el 7 de Jul. de 2019
Thanks very much! You saved my day (actually days)!

Iniciar sesión para comentar.

### Categorías

Más información sobre Analysis of Variance and Covariance en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by