1
{ ******************************************************************
2
Two-way analysis of variance (one observation per sample)
3
****************************************************************** }
11
NA = 3; { Number of modalities of factor A }
12
NB = 4; { Number of modalities of factor B }
13
Alpha = 0.05; { Significance level }
14
Prob = 1.0 - Alpha; { Probability }
16
{ The samples are stored in a matrix Z, such that
17
Z[I, J] contains the observation for the I-th
18
modality of factor A and the J-th modality of factor B }
21
Z : array[1..NA, 1..NB] of Float =
27
M : PMatrix; { Means }
28
S : PMatrix; { Standard deviations }
30
{ Note: The S matrix does not need to be dimensioned if there is
31
only one observation per sample. However, it must be declared. }
33
V : PVector; { Variances (A, B, interaction) }
34
DoF : PIntVector; { Degrees of freedom (A, B, interaction) }
35
F : PVector; { Variance ratios (A, B) }
36
Fc : PVector; { Critical values }
37
I, J : Integer; { Loop variables }
40
DimMatrix(M, NA, NB); { Means }
41
DimMatrix(S, NA, NB); { Standard deviations }
42
DimVector(V, 3); { Variances (A, B, interaction) }
43
DimIntVector(DoF, 3); { Degrees of freedom (A, B, interaction) }
44
DimVector(F, 2); { Variance ratios (A, B) }
45
DimVector(Fc, 2); { Critical values }
47
{ Compare means. The matrix of means is equal to the data matrix.
48
The matrix of standard deviations will be ignored. }
54
AnOVa2(NA, NB, 1, M, S, V, F, DoF);
56
{ Compute critical values }
58
Fc^[I] := InvSnedecor(DoF^[I], DoF^[3], Prob);
61
WriteLn('Two-way ANOVA');
63
WriteLn('Source Variance D.o.F. F F(p = ', Alpha:4:2, ')');
64
WriteLn('--------------------------------------------------------');
65
WriteLn('Factor A ', V^[1]:10:4, DoF^[1]:10, F^[1]:10:4, Fc^[1]:10:4);
66
WriteLn('Factor B ', V^[2]:10:4, DoF^[2]:10, F^[2]:10:4, Fc^[2]:10:4);
67
WriteLn('Interaction ', V^[3]:10:4, DoF^[3]:10);