# naginterfaces.library.anova.hier2¶

naginterfaces.library.anova.hier2(y, lsub, nobs)[source]

hier2 performs an analysis of variance for a two-way hierarchical classification with subgroups of possibly unequal size, and also computes the treatment group and subgroup means. A fixed effects model is assumed.

For full information please refer to the NAG Library document for g04ag

https://www.nag.com/numeric/nl/nagdoc_29.2/flhtml/g04/g04agf.html

Parameters
yfloat, array-like, shape

The elements of must contain the observations in the following order:

In words, the ordering is by group, and within each group is by subgroup, the members of each subgroup being in consecutive locations in .

lsubint, array-like, shape

The number of subgroups within group , , for .

nobsint, array-like, shape

The numbers of observations in each subgroup, , in the following order:

Returns
ngpint, ndarray, shape

The total number of observations in group , , for .

gbarfloat, ndarray, shape

The mean for group , , for .

sgbarfloat, ndarray, shape

The subgroup means, , in the following order:

gmfloat

The grand mean, .

ssfloat, ndarray, shape

Contains the sums of squares for the analysis of variance, as follows;

Between group sum of squares, ,

Between subgroup within groups sum of squares, ,

Residual sum of squares, ,

Corrected total sum of squares, .

idfint, ndarray, shape

Contains the degrees of freedom attributable to each sum of squares in the analysis of variance, as follows:

Degrees of freedom for between group sum of squares,

Degrees of freedom for between subgroup within groups sum of squares,

Degrees of freedom for residual sum of squares,

Degrees of freedom for corrected total sum of squares.

ffloat, ndarray, shape

Contains the mean square ratios, and , for the between groups variation, and the between subgroups within groups variation, with respect to the residual, respectively.

fpfloat, ndarray, shape

Contains the significances of the mean square ratios, and respectively.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

The total corrected sum of squares is zero.

(errno )

The residual sum of squares is zero.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

In a two-way hierarchical classification, there are () treatment groups, the th of which is subdivided into treatment subgroups. The th subgroup of group contains observations, which may be denoted by

The general observation is denoted by , being the th observation in subgroup of group , for , , .

The following quantities are computed

1. The subgroup means

2. The group means

3. The grand mean

4. The number of observations in each group

5. Sums of squares

 Between groups =SSg=∑ki=1ni.(¯y.i.−¯y…)2 Between subgroups within groups =SSsg=∑ki=1∑lij=1nij(y.ij−¯y.i.)2 Residual (within subgroups) =SSres=∑ki=1∑lij=1∑nijm=1(ymij−¯y.ij)2=SStot−SSg−SSsg Corrected total =SStot=∑ki=1∑lij=1∑nijm=1(ymij−¯y…)2
6. Degrees of freedom of variance components

 Between groups: k−1 Subgroups within groups: l−k Residual: n−l Total: n−1

where

,

7. ratios. These are the ratios of the group and subgroup mean squares to the residual mean square.

 Groups F1=Between groups sum of squares/(k−1)Residual sum of squares/(n−l)=SSg/(k−1)SSres/(n−l) Subgroups F2=Between subgroups (within group) sum of squares/(l−k)Residual sum of squares/(n−l)=SSsg/(l−k)SSres/(n−l)

If either ratio exceeds , the value is assigned instead.

8. significances. The probability of obtaining a value from the appropriate -distribution which exceeds the computed mean square ratio.

 Groups p1=Prob(F(k−1),(n−l)>F1) Subgroups p2=Prob(F(l−k),(n−l)>F2)

where denotes the central -distribution with degrees of freedom and .

If any , then is set to zero, .

References

Kendall, M G and Stuart, A, 1976, The Advanced Theory of Statistics (Volume 3), (3rd Edition), Griffin

Moore, P G, Shirley, E A and Edwards, D E, 1972, Standard Statistical Calculations, Pitman