image thumbnail

n-way ANOVA from summary statistics

version 1.0.0.0 (6.68 KB) by Peter Nagy
The program performs n-way ANOVA on data containing summary statistics (mean, SD and N) of groups.

538 Downloads

Updated 01 Apr 2013

View License

The program can perform n-way ANOVA (when run in 'calc' mode) on an array
which has been created by the program run in 'gen' (=generation) mode.
The program runs in different modes depending on the arguments:
- anovanFromSumStat('ver')
The version of the program is displayed.

- anovaArray=anovanFromSumStat('gen')
An array is created holding the means, SDs and number of elements in
each group of data. The program will ask for the number of factors and
you will have to give the number of levels of each factor using a GUI.
Then, the mean, SD and number of elements in each group will have to be
specified using another GUI. This GUI asks for the mean, SD and N in
the following manner:
mean SD N
A(1)B(1)C(1) - mean, SD and N of levels 1,1,1 of factors A,B,C, resp.
A(1)B(1)C(2) - mean, SD and N of levels 1,1,2 of factors A,B,C, resp.
The data will be saved in an array with the following structure:
First dimension: levels of the first factor
...
nth dimension: levels of the last factor
n+1 dimension: mean, SD and n of the group

- anovaArray=anovanFromSumStat('gen',[l1,l2,l3...])
The same as above but the number of levels of each factor
[l1,l2,l3,...] is given as the second argument.

- anovaArray=anovanFromSumStat('regen',anovaArray)
The program modifies the anovaArray created using the 'gen' option.

- varargout=anovanFromSumStat('calc',anovaArray)
The program evaluates the anovaArray created when running the program
with 'gen' as the first argument. The matrix of marginal means is
returned as the first output argument. Example for the structure of
this matrix:

means of the anovaArray: number of elements matrixOfMarginalMeans:
of the anovaArray:
1 2 3 10 20 30 1 2 3 2.33
4 5 6 40 50 60 4 5 6 5.13
3.4 4.1 5 4.33

(1*10+2*20+3*30)/(10+20+30)=2.33
(1*10+4*40)/(10+40)=3.4
The number in the lower right corner is the global mean.

Marginal frequencies are returned as the second output argument. The
structure of this matrix is the same as that of the first output
argument. For the example above:
10 20 30 60
40 50 60 150
50 70 90 210

Main effects and interaction effects are tested ('modell','full' option
of the anovan command of Matlab).
IF THE SAMPLE SIZES ARE UNEQUAL AND THE NUMBER OF FACTORS IS AT LEAST
TWO, THE HARMONIC MEAN OF THE SAMPLE SIZES IS USED (HOWELL:STATISTICAL
METHODS FOR PSYCHOLOGY). THIS WILL ONLY BE AN APPROXIMATION OF THE
RESULTS OBTAINED BY THE TYPE 3 SUM OF SQUARES USED BY MOST STATISTICAL
PROGRAMS (E.G. ANOVAN IN MATLAB, SPSS, SIGMASTAT).

Output arguments:
varargout{1}=marginal means
varargout{2}=marginal frequencies
varargout{3}=table of main and interaction effects. Each row
corresponds to a term, each column corresponds to a
factor. Those factors are calculated which have 1s in
their column. This specification is similar to how
'modeltype' interprets the main and interaction effects in
the anovan command of Matlab. The MS, SS, df, F and p
arrays are arranged according to this table.
varargout{4}=array of sums of squares (SS)
varargout{5}=array of mean squares (MS)
varargout{6}=array of degrees of freedom
varargout{7}=array of F
varargout{8}=array of p
varargout{9}=[SSwithin,MSwithin] (SSwithin is a.k.a. SSerror)
varargout{10}=[SSbetween,MSbetween] (SSbetween is a.k.a. SScells)
varargout{11}=SStot;

Cite As

Peter Nagy (2021). n-way ANOVA from summary statistics (https://www.mathworks.com/matlabcentral/fileexchange/41036-n-way-anova-from-summary-statistics), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!