File Exchange

image thumbnail


version (5.69 KB) by Antonio Trujillo-Ortiz
Three-way Analysis of Variance With Repeated Measures on Three Factors Test.


Updated 11 Oct 2006

View License

This is a three-factor analysis of variance design in which all factors are within-subjects variables. In repeated measures designs, the same participants are used in all conditions. This is like an extreme matching. This allows for reduction of error variance due to subject factors. Fewer participants can be used in an repeated measures design. Repeated measures designs make it easier to see an effect of the independent variable on the dependent variable (if there is such an effect).

Due that there is no way to obtain an independent estimate of error component, for we have only one score per cell, and therefore no within-cell variance. However, each of the interactions with subjects can be shown to serve as a denominator for an F ratio. So, each effect to be tested has its own error term. Thus every effect is tested by the interaction of that effect with the Subject effect.

X - data matrix (Size of matrix must be n-by-5;dependent variable=column 1; independent variable 1 (within subjects)=column 2;independent variable 2 (within subjects)=column 3; independent variable 3 (within subjects)=column 4; subject=column 5).
alpha - significance level (default = 0.05).
- Complete Analysis of Variance Table.

Cite As

Antonio Trujillo-Ortiz (2020). RMAOV33 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (17)

Danlei Chen


I usually enjoy your RM anova extensions to MATLAB and make use of them quite often. However, I have encountered a small glitch in this function:
When you calculate the within-subject sum of squares by summing up all the SS the SSAC term is added twice (see line 461).

Gert Faber

Oops, I made a mistake, I get the same results now

Gert Faber

And looking at my plots, results of SPSS seem to make more sense.

Olaf Dimigen

Function produces wrong output if (A) one of the factors has more than 10 levels and more than 10 subjects are used or (B) both factors have more than 10 levels.
The reason is that the "eval()" function is used to create temporary storage variables. Unfortunately, the result of "factorlevel 1" and "subject 11" is written into the the same variable "x111" as the result of "factorlevel 11" and "subject 1" (because both numbers are simply concatenated to produce the storage variable name), that is, the value of this variable is accidentally overwritten on subsequent iterations. This produces wrong results and also explains the negative F-values reported above.

Sauro Salomoni

Works great. Values are consistent with Statistica results. Thank you.

Alan Fermin

the code is excellent, easy to understand and to perform a test.
it accounts for within subject variance, but results are not much different from anovan. how to perform a post-hoc analysis, as the multicomparion in anovan?

Pichon Swann

Function Bugged ?
It returns negative SS values on some analyses and SS/F/p results differ significantly from RM ANOVA calculated using SPSS or Statistica.

Andreia Miana

This function is exactly what I was looking for, considering that this m-file is not available in matlab. In addition, the table and the explanation are very helpful. Thanks to the authors.

Michael Hamman

My Dear Ji Cling,

Regularly I visit this FEX site in which excellent contributions for the fast solution of diverse types of problems in several disciplines have been given. The accusation that you are causing is very delicate. I do not know you. Neither the authors. We known them only by the references given in their author page. Only what I believe is in the quality of ethics of each one of them and ours. We are serious people dedicated to our work in the most diverse specialties. To be certain what you say. Then not alone this author does cheating but also all the others. Even you, that in principle, I think you are not signing with your true name. Finally, or really the community are honestly dawnloaded the m-files or finally someone are doing a very bad play. This because there exists a lack of control on this.

Best Wishes.


Ji Cling

Shame on you.
Self downloading 1000ths of times to get to the top of the rank.

Clayton Hickey

Excellent tool, interpretable code. Thanks very much to the author. To comment on a comment, p.diddy is confused; anovan.m has no repeated measures functionality.

Alexander Kraskov

there is a bug in it
line 427:
is MSABC = SSABC/v10;
should be MSABC = SSABC/v13;

minor thing is that comment for lines 426,427 and 444, 445 are wrong, just copy/paste from lines 316,317, 332, 333

P Diddy

already available in matlab as function "anovan". anovan is much more intuitive than this m file, with respect to the data format that is fed into the function.

Marianne Maertens

The code works excellent and the documentation is extremely straightforward.


G. B.

Many thanks to the authors for this very useful and much-needed code! Works perfectly.

C. P.

I am a neurophysiologist and this m-file its just what I was needing. Thanks to the authors for their contribution.

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!