ANEST
Analyzes a completely nested random model with possibly unequal numbers in the subgroups.
Required Arguments
NF — Number of factors (number of subscripts) in the model including
error. (Input)
IEQ — Equal numbers option. (Input)
IEQ
Description
0
Unequal numbers in the subgroups
1
Equal numbers in the subgroups
NL — Vector with the number of levels. (Input)
If IEQ = 1, NL is of length NF and contains the number of levels for each of the factors. In this case, the following additional variables are referred to in the description of ANEST:
Variable
Description
LNL
NL(1) + NL(1) * NL(2) +  + NL(1) * NL(2) *  * NL(NF  1)
LNLNF
NL(1) * NL(2) * * NL(NF  1)
NOBS
The number of observations. NOBS equals NL(1) * NL(2) *  * NL(NF).
If IEQ = 0, NL contains the number of levels of each factor at each level of the factor in which it is nested. In this case, the following additional variables are referred to in the description of ANEST:
Variable
Description
LNL
Length of NL.
LNLNF
Length of the subvector of NL for the last factor.
NOBS
Number of observations. NOBS equals the sum of the last LNLNF elements of NL.
For example, a random one-way model with two groups, five responses in the first group and ten in the second group, would have LNL = 3, LNLNF = 2, NOBS = 15, NL(1) = 2, NL(2) = 5, and NL(3) = 10.
Y — Vector of length NOBS containing the responses. (Input)
The elements of Y are ordered lexicographically, i.e., the last model subscript changes most rapidly, the next next to last model subscript changes the next most rapidly, and so forth, with the first subscript changing the slowest.
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
CONPER — Confidence level for two-sided interval estimates on the variance components, in percent. (Input)
Default: CONPER = 95.0.
CONPER percent confidence intervals are computed, hence, CONPER must be in the interval [0.0, 100.0). CONPER often will be 90.0, 95.0, or 99.0. For one-sided intervals with confidence level ONECL, ONECL in the interval [50.0, 100.0), set
CONPER = 100.0 2.0 * (100.0 ONECL).
IPRINT — Printing option. (Input)
Default: IPRINT = 0.
IPRINT
Action
0
No printing is performed.
1
Printing is performed.
EMS — Vector of length (NF + 1) * NF/2 with expected mean square coefficients. (Output)
VCNF by 9 matrix containing statistics relating to the particular variance components in the model. (Output)
Rows of VC correspond to the NF factors. Columns of VC are as follows:
Column
Description
1
Degrees of freedom
2
Sum of squares
3
Mean squares
4
F-statistic
5
p-value for F test
6
Variance component estimate
7
Percent of variance explained by variance component
8
Lower endpoint for a confidence interval on the variance component
9
Upper endpoint for a confidence interval on the variance component
A test for the error variance equal to zero cannot be performed. VC(NF, 4) and
VC(NF, 5) are set to NaN (not a number).
LDVC — Leading dimension of VC exactly as specified in the dimension statement in the calling program. (Input)
Default: LDVC= size(VC ,1)
YMEANS — Vector containing the subgroup means. (Output)
IEQ
Length of YMEANS
0
1 + NL(1) + NL(2) +  NL(LNL LNLNF) (See the description of argument NL for definitions of LNL and LNLNF.)
1
1 + NL(1) + NL(1) * NL(2) +  + NL(1) * NL(2) * * NL(NF 1)
If the factors are labeled A, B, C, and error, the ordering of the means is grand mean,
A means, AB means, and then ABC means.
NMISS — Number of missing values in Y. (Output)
Elements of Y equal to NaN (not a number) are omitted from the computations.
FORTRAN 90 Interface
Generic: CALL ANEST (NF, IEQ, NL, Y, AOV [])
Specific: The specific interface names are S_ANEST and D_ANEST.
FORTRAN 77 Interface
Single: CALL ANEST (NF, IEQ, NL, Y, CONPER, IPRINT, AOV, EMS, VC, LDVC, YMEANS, NMISS)
Double: The double precision name is DANEST.
Description
Routine ANEST analyzes a nested random model with equal or unequal numbers in the subgroups. The analysis includes an analysis of variance table and computation of subgroup means and variance component estimates. Anderson and Bancroft (1952, pages 325330) discuss the methodology. The analysis of variance method is used for estimating the variance components. This method solves a linear system in which the mean squares are set to the expected mean squares. A problem that Hocking (1985, pages 324330) discusses is that this method can yield negative variance component estimates. Hocking suggests a diagnostic procedure for locating the cause of a negative estimate. It may be necessary to reexamine the assumptions of the model.
Comments
Workspace may be explicitly provided, if desired, by use of A2EST/DA2EST. The reference is:
CALL A2EST (NF, IEQ, NL, Y, CONPER, IPRINT, AOV, EMS, VC, LDVC, YMEANS, NMISS, WK, IWK, CHWK)
The additional arguments are as follows:
WK — Work vector of length NOBS.
IWK — Work vector of length 5 * NF + (2 * LNL LNLNF).
CHWKCHARACTER * 10 vector of length 2 * NF + 1. If IPRINT = 0, CHWK is not referenced and can be a vector of length one.
Examples
Example 1
An analysis of a three-factor nested random model with equal numbers in the subgroups is performed using data discussed by Snedecor and Cochran (1967, Table 10.16.1, pages 285288). The responses are calcium concentrations (in percent, dry basis) as measured in the leaves of turnip greens. Four plants are taken at random, then three leaves are randomly selected from each plant. Finally, from each selected leaf two samples are taken to determine calcium concentration. The model is
yijk = μ + α i + βjj + eijk     i = 1, 2, 3, 4; j = 1, 2, 3; k = 1, 2
where yijk is the calcium concentration for the k-th sample of the j-th leaf of the i-th plant, the α i’s are the plant effects and are taken to be independently distributed
the βij’s are leaf effects each independently distributed
and the ɛ ijk’s are errors each independently distributed N(0, σ2). The effects are all assumed to be independently distributed. The data are given in the following table:
Plant
Leaf
Samples
1
1
2
3
3.28
3.52
2.88
3.09
3.48
2.80
2
1
2
3
2.46
1.87
2.19
2.44
1.92
2.19
3
1
2
3
2.77
3.74
2.55
2.66
3.44
2.55
4
1
2
3
3.78
4.07
3.31
3.87
4.12
3.31
 
USE ANEST_INT
 
IMPLICIT NONE
INTEGER NF, NOBS
PARAMETER (NF=3, NOBS=24)
!
INTEGER IEQ, IPRINT, NL(NF)
REAL AOV(15), Y(NOBS)
!
DATA Y/3.28, 3.09, 3.52, 3.48, 2.88, 2.80, 2.46, 2.44, 1.87, &
1.92, 2.19, 2.19, 2.77, 2.66, 3.74, 3.44, 2.55, 2.55, 3.78, &
3.87, 4.07, 4.12, 3.31, 3.31/
DATA NL/4, 3, 2/
!
IEQ = 1
IPRINT = 1
CALL ANEST (NF, IEQ, NL, Y, 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 99.222 98.510 0.08158 3.012 2.708
 
* * * Analysis of Variance * * *
Sum of Mean Prob. of
Source DF Squares Square Overall F Larger F
Model 11 10.19 0.9264 139.216 0.0000
Error 12 0.08 0.0067
Corrected Total 23 10.27
Sum of Mean Prob. of
Source DF Squares Square F Larger F
A 3 7.56034 2.52011 7.665 0.0097
B 8 2.63020 0.32878 49.406 0.0000
 
* * * Expected Mean Square Coefficients * * *
Error Effect B Effect A
Effect A 1 2 6
Effect B 1 2
Error 1
 
* * * Variance Components * * *
95.0% Confidence Interval
Variance --------------------------
Component Estimate Percent Lower Limit Upper Limit
A 0.36522 68.530 0.039551 5.7867
B 0.16106 30.221 0.069669 0.6004
Error 0.00665 1.249 0.003422 0.0181
 
A Means
1 3.1750
2 2.1783
3 2.9517
4 3.7433
 
AB Means
1 1 3.1850
1 2 3.5000
1 3 2.8400
2 1 2.4500
2 2 1.8950
2 3 2.1900
3 1 2.7150
3 2 3.5900
3 3 2.5500
4 1 3.8250
4 2 4.0950
4 3 3.3100
Example 2
An analysis of a three-factor nested random model with unequal numbers in the subgroups is performed. The data are given in the following table:
A
B
C
1
1
2
23.0
31.0
19.0
37.0
 
2
1
2
33.0
29.0
29.0
 
3
1
36.0
29.0
33.0
4
1
2
3
4
5
6
7
8
9
11.0
23.0
33.0
23.0
26.0
39.0
20.0
24.0
36.0
21.0
18.0
 
5
1
25.0
33.0
 
6
1
2
3
4
5
6
7
8
9
10
28.0
25.0
32.0
41.0
35.0
16.0
30.0
40.0
32.0
44.0
31.0
42.0
36.0
 
 
USE ANEST_INT
 
IMPLICIT NONE
INTEGER LNL, NF, NOBS
PARAMETER (LNL=32, NF=3, NOBS=36)
!
INTEGER IEQ, IPRINT, NL(LNL)
REAL AOV(15), Y(NOBS)
!
DATA Y/23.0, 19.0, 31.0, 37.0, 33.0, 29.0, 29.0, 36.0, 29.0, &
33.0, 11.0, 21.0, 23.0, 18.0, 33.0, 23.0, 26.0, 39.0, 20.0, &
24.0, 36.0, 25.0, 33.0, 28.0, 31.0, 25.0, 42.0, 32.0, 36.0, &
41.0, 35.0, 16.0, 30.0, 40.0, 32.0, 44.0/
DATA NL/6, 2, 2, 1, 9, 1, 10, 2, 2, 2, 1, 3, 2, 2, 1, 1, 1, 1, &
1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1/
!
IEQ = 0
IPRINT = 1
CALL ANEST (NF, IEQ, NL, Y, 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 85.376 53.470 5.31 29.53 17.98
 
* * * Analysis of Variance * * *
Sum of Mean Prob. of
Source DF Squares Square Overall F Larger F
Model 24 1810.8 75.45 2.676 0.0459
Error 11 310.2 28.20
Corrected Total 35 2121.0
 
Sum of Mean Prob. of
Source DF Squares Square F Larger F
A 5 461.42 92.2845 0.988 0.4601
B 19 1349.38 71.0202 2.519 0.0597
 
* * * Expected Mean Square Coefficients * * *
Error Effect B Effect A
Effect A 1.00000 1.96503 5.37778
Effect B 1.00000 1.28990
Error 1.00000
 
* * * Variance Components * * *
95.0% Confidence Interval
Variance --------------------------
Component Estimate Percent Lower Limit Upper Limit
A -0.214 NaN NaN NaN
B 33.199 54.073 0.00 100.59
Error 28.197 45.927 14.15 81.29
 
A Means
1 27.5000
2 30.3333
3 32.6667
4 24.9091
5 29.0000
6 33.2308
AB Means
1 1 21.0000
1 2 34.0000
2 1 31.0000
2 2 29.0000
3 1 32.6667
4 1 16.0000
4 2 20.5000
4 3 33.0000
4 4 23.0000
4 5 26.0000
4 6 39.0000
4 7 20.0000
4 8 24.0000
4 9 36.0000
5 1 29.0000
6 1 29.5000
6 2 33.5000
6 3 34.0000
6 4 41.0000
6 5 35.0000
6 6 16.0000
6 7 30.0000
6 8 40.0000
6 9 32.0000
6 10 44.0000