One- and two-way ANOVA

View: New views
4 Messages — Rating Filter:   Alert me  

One- and two-way ANOVA

by Dupuis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm getting ready to analyse a measurement campaign involving two factors ... and noticed the Octave implementation of ANOVA can only deal with one factor. I modified it a bit, to perform one-way of
two-way ANOVA according to the input:
- call with one argument => it must be a matrix, rows are repetitions, each column is associated with one level of a factor. One-way ANOVA.
- call with two arguments
  - both are vectors => data and one set of group. One-way.
  - first is a matrix, the second is either a vector whose length is equal to the number of rows of the matrix, either a matrix of the same size => each colum is associated with one level of the 'column'

For one-way, computes the Within-group, Bewteen-group and Total sum-of-squares, with are further scaled to compute corresponding variances and F test. For two-way, the within-group is split as row
factor, colum factor and interaction. This produces three variances and F test.

The target is different from MANOVA, which rests upon the hypothesis that data in one group are samples of a normal distribution with VECTOR mean and a square variance-covariance matrix.

The working was verified against data published on
1)http://www.itl.nist.gov/div898/handbook/prc/section4/prc438.htm
2)http://faculty.vassar.edu/lowry/ch16pt2.html
Note that in the second exemple given in http://faculty.vassar.edu/lowry/ch16pt3.html¸there is a small mistake in the computations, the SST is slightly incorrect.

Would it be possible to test the enclosed file, and replace
/usr/share/octave/3.0.0/m/statistics/tests/anova.m
with it ? As the old behaviour, in the case of one-way, is unmodified, I guess there shouldn't be a name change.

Regards

Pascal Dupuis

anova.m.diff

One- and two-way ANOVA; One-way ANCOVA

by Dupuis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is a followup of the previous message. I enclose a version of ANOVA which can perform one-factor and two-factors analysis, as well as taking into account the fact that, for one-way, entries are correlated, like f.i. repeated measures, or experiments where subjects undergo some tests under varying conditions.

I also wrote a program to perform ANCOVA, analysis of covariance. The inputs are a set of (x, y) pairs; the goal is to test wether or not the difference in y means is significant, taking into account the x-y correlations.

John, could you include both in m/statistics/tests/ ?

Regards

Pascal
ancova.m
anova.m.diff

Re: One- and two-way ANOVA; One-way ANCOVA

by Dupuis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Still another version ...
This one also display R2 and R2-adj. Both notions are explained at http://en.wikipedia.org/wiki/Coefficient_of_determination
the second is dependant of the number of coefficients of the model, it permits to assert whether or not adding or removing terms leads to better predictions.

Regards

Pascal
anova.m.diff
ancova.m

Re: One- and two-way ANOVA; One-way ANCOVA

by Dupuis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There was a bug in the ANCOVA computation of intermediate values. As a bonus, now the global slope and adjusted means for y are also displayed.

Regards

Pascal

ancova.m