ANWAY
Analyzes a balanced n-way classification model with fixed effects.
Required Arguments
NF — Number of factors (number of subscripts) in the model including
error. (Input)
NL — Vector of length NF containing the number of levels for each of the factors. (Input)
Y — Vector of length NL(1) * NL(2) * * NL(NF) containing the responses. (Input)
Y must not contain NaN (not a number) for any of its elements, i.e., missing values are not allowed.
INTERA — Interaction option. (Input)
The absolute value of INTERA is the number of factors to be included in the highest-way interaction in the model. The sign of INTERA indicates if factor NF is error.
INTERA
Meaning
< 0
Factor NF is not error. Only (‑INTERA + 1)-way and higher-way interactions are included in error.
> 0
Factor NF is error. Its main effect and all its interaction effects are pooled into the error with the other (INTERA + 1)-way and higher-way
AOV — Vector of length 15 containing statistics relating to the analysis of variance. (Output)
I
AOV(I)
1
Degrees of freedom for regression
2
Degrees of freedom for error
3
Total degrees of freedom
4
Sum of squares for regression
5
Sum of squares for error
6
Total sum of squares
7
Regression mean square
8
Error mean square
9
F-statistic
10
p-value
11
R2 (in percent)
12
Adjusted R2 (in percent)
13
Estimated standard deviation of the model error
14
Mean of the response (dependent) variable
15
Coefficient of variation (in percent)
Optional Arguments
IPRINT — Printing option. (Input)
Default: IPRINT = 0.
IPRINT
Action
0
Printing is not performed.
1
AOV and EFSS are printed.
2, 2
Only marginal means are printed. If IPRINT = 2, then all of YMEANS is printed. If IPRINT = 2, then marginal means higher than (INTERA) -way are not printed.
3, 3
AOV, EFSS, and all or some of YMEANS is printed. If IPRINT = 3, then all of YMEANS is printed. If IPRINT = 3, then marginal means higher than(INTERA) -way are not printed.
EFSSNEF by 4 matrix containing statistics relating to the sums of squares for the effects in the model. (Output)
Here, NEF= BINOM(n, 1) + BINOM(n, 2) +  + BINOM(n, INTERA) where the IMSL subroutine BINOM (IMSL MATH/LIBRARY Special Functions) returns the binomial coefficient, and n is given by
Suppose the factors are A, B, C, and error. With INTERA = 3, rows 1 through NEF would correspond to A, B, C, AB, AC, BC, and ABC, respectively. The columns of EFSS are as follows:
Column
Description
1
Degrees of freedom
2
Sum of squares
3
F -statistic
4
p-value
LDEFSS — Leading dimension of EFSS exactly as specified in the dimension statement in the calling program. (Input)
Deafult: LDEFSS = size (EFSS , 1)
YMEANS — Vector of length (NL(1) + 1) * (NL(2) + 1) * * (NL(n) + 1) containing subgroup means. (Output)
See argument EFSS for a definition of n. Suppose that the factors are A, B, C, and error. The ordering of the means is grand mean, A means, B means, C means, AB means, AC means, BC means, and ABC means.
FORTRAN 90 Interface
Generic: CALL ANWAY (NF, NL, Y, INTERA, AOV [])
Specific: The specific interface names are S_ANWAY and D_ANWAY.
FORTRAN 77 Interface
Single: CALL ANWAY (NF, NL, Y, INTERA, IPRINT, AOV, EFSS, LDEFSS, YMEANS)
Double: The double precision name is DANWAY.
Description
Routine ANWAY performs an analysis for an n-way classification design with balanced data. For balanced data, there must be an equal number of responses in each cell of the n-way layout. The effects are assumed to be fixed effects. The model is an extension of the twoway model to include n factors. The interactions (two-way, three-way, up to n-way) can be included in the model, or some of the higher-way interactions can be pooled into error. The argument INTERA specifies which interactions are to be pooled into error. For example, if three-way and higher-way interactions are to be pooled into error, set INTERA =  2 or INTERA = 2. A positive INTERA indicates there are repeated responses within the n-way cells, while a negative INTERA indicates otherwise.
Routine ANWAY requires the responses as input into a single vector Y in lexicographical order so that the response subscript associated with the first factor varies least rapidly, the subscript associated with the second factor varies next most rapidly, and so forth. Hemmerle (1967, Chapter 5) discusses the computational method.
Comments
Workspace may be explicitly provided, if desired, by use of A2WAY/DA2WAY. The reference is:
CALL A2WAY (NF, NL, Y, INTERA, IPRINT, AOV, EFSS, LDEFSS, YMEANS, WK, IWK)
The additional arguments are as follows:
WK — Work vector of length 5 * 2n + NMEANS + 4.
IWK — Work vector of length (NF + 2) * 2NF-1 + (n + 2) * 2n1 + n 2.
Examples
Example 1
A two-way analysis of variance is performed with balanced data discussed by Snedecor and Cochran (1967, Table 12.5.1, page 347). The responses are the weight gains (in grams) of rats fed diets varying in two components—source of protein (A) and level of protein (B). Here, INTERA = 2 is used. The model is
yijk = μ + αi + βj + γij + ɛijk    i = 1, 2; j = 1, 2, 3; k = 1, 2, , 10
where
for j = 1, 2, 3; and
for i = 1, 2.
The first responses in each cell in the two-way layout are given in the following table:
Protein Source (A)
Protein Level (B)
Beef
Cereal
Pork
High
73, 102, 118, 104, 81, 107, 100, 87, 117, 111
98, 74, 56, 111, 95, 88, 82, 77, 86, 92
94, 79, 96, 98, 102, 102, 108, 91, 120, 105
Low
90, 76, 90, 64, 86, 51, 72, 90, 95, 78
107, 95, 97, 80, 98, 74, 74, 67, 89, 58
49, 82, 73, 86, 81, 97, 106, 70, 61, 82
 
USE ANWAY_INT
 
IMPLICIT NONE
INTEGER NF, NOBS
PARAMETER (NF=3, NOBS=60)
!
INTEGER INTERA, IPRINT, NL(NF)
REAL AOV(15), Y(NOBS)
!
DATA Y/73.0, 102.0, 118.0, 104.0, 81.0, 107.0, 100.0, 87.0, &
117.0, 111.0, 90.0, 76.0, 90.0, 64.0, 86.0, 51.0, 72.0, &
90.0, 95.0, 78.0, 98.0, 74.0, 56.0, 111.0, 95.0, 88.0, &
82.0, 77.0, 86.0, 92.0, 107.0, 95.0, 97.0, 80.0, 98.0, &
74.0, 74.0, 67.0, 89.0, 58.0, 94.0, 79.0, 96.0, 98.0, &
102.0, 102.0, 108.0, 91.0, 120.0, 105.0, 49.0, 82.0, 73.0, &
86.0, 81.0, 97.0, 106.0, 70.0, 61.0, 82.0/
DATA NL/3, 2, 10/
!
INTERA = 2
IPRINT = 3
CALL ANWAY (NF, NL, Y, INTERA, AOV, IPRINT=IPRINT)
END
Output
 
Dependent R-squared Adjusted Est. Std. Dev. Coefficient of
Variable (percent) R-squared of Model Error Mean Var. (percent)
Y 28.477 21.854 14.65 87.87 16.67
 
* * * Analysis of Variance * * *
Sum of Mean Prob. of
Source DF Squares Square Overall F Larger F
Model 5 4612.9 922.6 4.300 0.0023
Error 54 11586.0 214.6
Corrected Total 59 16198.9
 
* * * Variation Due to the Model * * *
Sum of Prob. of
Source DF Squares F Larger F
A 2 266.53 0.621 0.5411
B 1 3168.27 14.767 0.0003
A*B 2 1178.13 2.746 0.0732
 
* * * Subgroup Means * * *
A Means (N=20)
1 89.6000
2 84.9000
3 89.1000
B Means (N=30)
1 95.1333
2 80.6000
A*B Means (N=10)
1 1 100.0000
1 2 79.2000
2 1 85.9000
2 2 83.9000
3 1 99.5000
3 2 78.7000
Example 2
This example performs a three-way analysis of variance using data discussed by John (1971, pages 9192). The responses are weights (in grams) of roots of carrots grown with varying amounts of applied nitrogen (A), potassium (B), and phosphorus (C). There is one response within each cell of the three-way layout. INTERA is set to 2 in order to pool the ABC three-factor interaction into error. (Note that the ABC interaction sum of squares, which is 186, is given incorrectly by John [1971, Table 5.2].) IPRINT is set to 3 so that the ABC means will not be printed (since INTERA is equal to 2). The three-way layout is given in the following table:
 
A0
A1
A2
 
B0
B1
B2
B0
B1
B2
B0
B1
B2
C0
88.76
91.41
97.85
94.83
100.49
99.75
99.90
100.23
104.51
C1
87.45
98.27
95.85
84.57
97.20
112.30
92.98
107.77
110.94
C2
86.01
104.20
90.09
81.06
120.80
108.77
94.72
118.39
102.87
 
USE ANWAY_INT
 
IMPLICIT NONE
INTEGER NF, NOBS
PARAMETER (NF=3, NOBS=27)
!
INTEGER INTERA, IPRINT, NL(NF)
REAL AOV(15), Y(NOBS)
!
DATA Y/88.76, 87.45, 86.01, 91.41, 98.27, 104.20, 97.85, 95.85, &
90.09, 94.83, 84.57, 81.06, 100.49, 97.20, 120.8, 99.75, &
112.30, 108.77, 99.9, 92.98, 94.72, 100.23, 107.77, 118.39, &
104.51, 110.94, 102.87/
DATA NL/3, 3, 3/
!
INTERA = -2
IPRINT = -3
CALL ANWAY (NF, NL, Y, INTERA, AOV, IPRINT=IPRINT)
END
Output
 
Dependent R-squared Adjusted Est. Std. Dev. Coefficient of
Variable (percent) R-squared of Model Error Mean Var. (percent)
Y 92.804 76.612 4.819 98.96 4.869
 
 
* * * Analysis of Variance * * *
Sum of Mean Prob. of
Source DF Squares Square Overall F Larger F
Model 18 2395.7 133.1 5.731 0.0083
Error 8 185.8 23.2
Corrected Total 26 2581.5
 
* * * Variation Due to the Model * * *
Sum of Prob. of
Source DF Squares F Larger F
A 2 488.37 10.515 0.0058
B 2 1090.66 23.483 0.0004
C 2 49.15 1.058 0.3911
A*B 4 142.59 1.535 0.2804
A*C 4 32.35 0.348 0.8383
B*C 4 592.62 6.380 0.0131
 
* * * Subgroup Means * * *
A Means (N=9)
1 93.3211
2 99.9744
3 103.5900
 
B Means (N=9)
1 90.0311
2 104.3067
3 102.5478
C Means (N=9)
1 97.5256
2 98.5922
3 100.7678
A*B Means (N=3)
1 1 87.4067
1 2 97.9600
1 3 94.5967
2 1 86.8200
2 2 106.1633
2 3 106.9400
3 1 95.8667
3 2 108.7967
3 3 106.1067
A*C Means (N=3)
1 1 92.6733
1 2 93.8567
1 3 93.4333
2 1 98.3567
2 2 98.0233
2 3 103.5433
3 1 101.5467
3 2 103.8967
3 3 105.3267
B*C Means (N=3)
1 1 94.4967
1 2 88.3333
1 3 87.2633
2 1 97.3767
2 2 101.0800
2 3 114.4633
3 1 100.7033
3 2 106.3633
3 3 100.5767
Published date: 03/19/2020
Last modified date: 03/19/2020