Two-way repeated measures ANOVA
by Aaron Schurger
07 Feb 2005
(Updated 24 Jul 2011)
Two-way repeated measures ANOVA, for designs with two within-subjects variables.
|
Watch this File
|
| File Information |
| Description |
%
% function stats = rm_anova2(Y,S,F1,F2,FACTNAMES)
%
% Two-factor, within-subject repeated measures ANOVA.
% For designs with two within-subject factors.
%
% Parameters:
% Y dependent variable (numeric) in a column vector
% S grouping variable for SUBJECT
% F1 grouping variable for factor #1
% F2 grouping variable for factor #2
% FACTNAMES a cell array w/ two char arrays: {'factor1', 'factor2'}
%
% Y should be a 1-d column vector with all of your data (numeric).
% The grouping variables should also be 1-d numeric, each with same
% length as Y. Each entry in each of the grouping vectors indicates the
% level # (or subject #) of the corresponding entry in Y.
%
% Returns:
% stats is a cell array with the usual ANOVA table:
% Source / ss / df / ms / F / p
%
% Notes:
% Program does not do any input validation, so it is up to you to make
% sure that you have passed in the parameters in the correct form:
%
% Y, S, F1, and F2 must be numeric vectors all of the same length.
%
% There must be at least one value in Y for each possible combination
% of S, F1, and F2 (i.e. there must be at least one measurement per
% subject per condition).
%
% If there is more than one measurement per subject X condition, then
% the program will take the mean of those measurements.
%
% Aaron Schurger (2005.02.04)
% Derived from Keppel & Wickens (2004) "Design and Analysis" ch. 18
%
|
| Required Products |
Statistics Toolbox
|
| MATLAB release |
MATLAB 6.5.1 (R13SP1)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (23) |
| 29 Apr 2005 |
Aaron Schurger
|
|
|
| 22 Jul 2005 |
Ted Zanto
|
|
|
| 02 Feb 2006 |
dojoon yi
|
|
|
| 27 Feb 2006 |
Teck Por Lim
|
|
|
| 13 Dec 2006 |
adam mcnamara
|
|
|
| 28 Jun 2007 |
malia mason
|
|
|
| 18 Feb 2008 |
Ashwin Sundar
|
|
|
| 16 Mar 2008 |
Perspicacity Slim
|
|
|
| 23 Mar 2008 |
keidit chankhachon
|
|
|
| 07 Apr 2008 |
terence hill
|
|
|
| 24 Jul 2008 |
piyush singhal
|
|
|
| 17 Jun 2009 |
Zachary Danziger
|
|
|
| 17 Jul 2009 |
Aaron Schurger
|
|
|
| 19 Nov 2009 |
Negar
|
|
|
| 31 Dec 2009 |
Robert
|
|
|
| 23 Feb 2010 |
Alberich Qi
|
|
|
| 22 Apr 2010 |
Marieke Rohde
|
|
|
| 29 Apr 2010 |
Jamie
|
|
|
| 27 Apr 2011 |
titou
|
|
|
| 06 May 2011 |
Marieke Rohde
|
|
|
| 06 Jul 2011 |
Erin
|
|
|
| 11 Oct 2011 |
Marieke
|
|
|
| 10 Dec 2011 |
Jordan
|
|
|
| Updates |
| 02 May 2005 |
An error on line 70 of the code produced errors if you ran the ANOVA on your raw data, without having previously averaged the measurements within each cell. This feature now works correctly. |
| 31 May 2005 |
There was a minor problem in the code (line 70) which would produce inaccurate results if you did not average your data within each condition prior to calling the function. This is now fixed. |
| 05 Oct 2005 |
Reviewer Ted Zanto (zanto@ccs.fau.edu) noticed a minor error on line 133: FACTNAMES{1} should be FACTNAMES{2}. Corrected this error. This error would have been of little or no consequence to users of the program. |
| 11 Dec 2009 |
Fixed a minor error in the code. Uploaded new version. I had fixed this problem quite a while back, and uploaded the file. It may not have uploaded properly the first time. Thanks to Johan Carlin for bringing the problem to my attention. |
| 24 Jul 2011 |
Fixed one minor error in the labeling of the output, and also modified the comments. |
|
Contact us at files@mathworks.com