naginterfaces.library.anova.contrasts

naginterfaces.library.anova.contrasts(tmean, irep, rms, rdf, ct, tabl, tol, usetx, tx)[source]

contrasts computes sum of squares for a user-defined contrast between means.

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

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g04/g04daf.html

Parameters
tmeanfloat, array-like, shape

The treatment means, , for .

irepint, array-like, shape

The replication for each treatment mean, , for .

rmsfloat

The residual mean square, .

rdffloat

The residual degrees of freedom.

ctfloat, array-like, shape

The columns of must contain the contrasts, that is must contain , for , for .

tablfloat, array-like, shape

The elements of that are not referenced as described below remain unchanged.

tolfloat

The tolerance, used to check if the contrasts are orthogonal and if they are orthogonal to the mean. If the value machine precision is used.

usetxbool

If the means are provided in and the formula (2) is used instead of formula (1).

If formula (1) is used and is not referenced.

txfloat, array-like, shape

If must contain the means , for .

Returns
estfloat, ndarray, shape

The estimates of the contrast, , for .

tablfloat, ndarray, shape

The rows of the analysis of variance table for the contrasts. For each row column 1 contains the degrees of freedom, column 2 contains the sum of squares, column 3 contains the mean square, column 4 the -statistic and column 5 the significance level for the contrast. Note that the degrees of freedom are always one and so the mean square equals the sum of squares.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

The and contrasts are not orthogonal.

(errno )

The contrast is not orthogonal to the mean.

Notes

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

In the analysis of designed experiments the first stage is to compute the basic analysis of variance table, the estimate of the error variance (the residual or error mean square), , and the (variance ratio) -statistic for the treatments. If this -test is significant then the second stage of the analysis is to explore which treatments are significantly different.

If there is a structure to the treatments then this may lead to hypotheses that can be defined before the analysis and tested using linear contrasts. For example, if the treatments were three different fixed temperatures, say , and , and an uncontrolled temperature (denoted by ) then the following contrasts might be of interest.

The first represents the average difference between the controlled temperatures and the uncontrolled temperature. The second represents the linear effect of an increasing fixed temperature.

For a randomized complete block design or a completely randomized design, let the treatment means be , , and let the th contrast be defined by , , then the estimate of the contrast is simply:

and the sum of squares for the contrast is:

where is the number of observations for the th treatment. Such a contrast has one degree of freedom so that the appropriate -statistic is .

The two contrasts and are orthogonal if and the contrast is orthogonal to the overall mean if . In practice these sums will be tested against a small quantity, . If each of a set of contrasts is orthogonal to the mean and they are all mutually orthogonal then the contrasts provide a partition of the treatment sum of squares into independent components. Hence the resulting -tests are independent.

If the treatments come from a design in which treatments are not orthogonal to blocks then the sum of squares for a contrast is given by:

where

with , for , being adjusted treatment means computed by first eliminating blocks then computing the treatment means from the block adjusted observations without taking into account the non-orthogonality between treatments and blocks. For further details see John (1987).

References

Cochran, W G and Cox, G M, 1957, Experimental Designs, Wiley

John, J A, 1987, Cyclic Designs, Chapman and Hall

Winer, B J, 1970, Statistical Principles in Experimental Design, McGraw–Hill