File Exchange

image thumbnail


version (4.27 KB) by Antonio Trujillo-Ortiz
Repeated measures two-way analysis of variance test.

1 Download

Updated 03 Aug 2004

View License

ANOVA with two within-subject variables is used to analyze the relationship between two independent variables and the dependent variable. This procedure requires fewer participants but can give rise to research confounds such as order or practice effects and participant bias.

For a more detailed explanation on repeated measures designs, we suggest you read the help section of the RMAOV1 file you can find on this MATLAB File Exchange site.

It needs to input the X- data matrix (Size of matrix must be n-by-4;dependent variable=column 1;independent variable 1=column 2;independent variable 2=column 3;subject=column 4) and the alpha-significance level (default = 0.05).

The output is a complete Analysis of Variance table and the strength of the relationships.

Comments and Ratings (12)


The function has an output argument, but nothing is assigned to it.

How can we add the fdr correction on this statistic??


Warning. This function (and apparently all other ANOVA functions by this author) produces a 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, "factorlevel 1" and "subject 11" and "factorlevel 11" and "subject 1" are written into the same storage variable with the concatenated name "x111", that is, the value of this variable is accidentally overwritten. This produces wrong results and also explains the negative F-values reported above.

- I encountered negative SS values, and consequently negative Fs
- the output differed from SPSS output both with SS model II and III, and from rm_anova2.m that uses SS model III and gives the same results as SPSS

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.

Arturo Ramírez

Patrick Craston

Thanks for great code!

Richard Born

Works for me. However, unlike the toolbox function, anovan, the grouping variables must be consecutive integers, 1:n. This will be fixed by:

function [Gred] = facred(G)

% G is the orginal matrix of grouping variables:
% each row for is an observation; each column is a different grouping variable.
Gred = G;
for k = 1:size(G,2)
groups = sort(unique(G(:,k)));

for m = 1:length(groups)
t = find(G(:,k) == groups(m));
Gred(t,k) = m;

J. D.

Good code.

L. G.

My friends think this is great and told me to download it.


It was added an appropriate format to cite this file.

It was added an appropriate format to cite this file.

It was added an appropriate format to cite this file.

It was added an appropriate format to cite this file.

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