NAG Library Function Document
nag_anova_confid_interval (g04dbc) computes simultaneous confidence intervals for the differences between means. It is intended for use after nag_anova_random (g04bbc)
or nag_anova_row_col (g04bcc)
||nag_anova_confid_interval (Nag_IntervalType type,
const double tmean,
const double c,
In the computation of analysis of a designed experiment the first stage is to compute the basic analysis of variance table, the estimate of the error variance (the residual or error mean square), , the residual degrees of freedom, , and the (variance ratio) -statistic for the treatments. The second stage of the analysis is to compare the treatment means. If the treatments have no structure, for example the treatments are different varieties, rather than being structured, for example a set of different temperatures, then a multiple comparison procedure can be used.
A multiple comparison procedure looks at all possible pairs of means and either computes confidence intervals for the difference in means or performs a suitable test on the difference. If there are treatments then there are comparisons to be considered. In tests the type 1 error or significance level is the probability that the result is considered to be significant when there is no difference in the means. If the usual -test is used with, say, a five percent significance level then the type 1 error for all tests will be much higher. If the tests were independent then if each test is carried out at the percent level then the overall type 1 error would be . In order to provide an overall protection the individual tests, or confidence intervals, would have to be carried out at a value of such that is the required significance level, e.g., five percent.
percent confidence interval for the difference in two treatment means,
is given by
denotes the standard error of the difference in means and
is an appropriate percentage point from a distribution. There are several possible choices for
. These are:
||, the studentized range statistic. It is the appropriate statistic to compare the largest mean with the smallest mean. This is known as Tukey–Kramer method.
||, this is the Bonferroni method.
||, where , this is known as the Dunn–Sidak method.
||, this is known as Fisher's LSD (least significant difference) method. It should only be used if the overall -test is significant, the number of treatment comparisons is small and were planned before the analysis.
|| where is the deviate corresponding to a lower tail probability of from an -distribution with and degrees of freedom. This is Scheffe's method.
In cases (b)
two-tail significance level for the Student's
degrees of freedom, see nag_deviates_students_t (g01fbc)
The Scheffe method is the most conservative, followed closely by the Dunn–Sidak and Tukey–Kramer methods.
To compute a test for the difference between two means the statistic,
is compared with the appropriate value of
Kotz S and Johnson N L (ed.) (1985a) Multiple range and associated test procedures Encyclopedia of Statistical Sciences 5 Wiley, New York
Kotz S and Johnson N L (ed.) (1985b) Multiple comparison Encyclopedia of Statistical Sciences 5 Wiley, New York
Winer B J (1970) Statistical Principles in Experimental Design McGraw–Hill
type – Nag_IntervalTypeInput
: indicates which method is to be used.
- The Tukey–Kramer method is used.
- The Bonferroni method is used.
- The Dunn–Sidak method is used.
- The Fisher LSD method is used.
- The Scheffe's method is used.
, , , or .
nt – IntegerInput
On entry: the number of treatment means, .
tmean[nt] – const doubleInput
On entry: contains the treatment means, , .
rdf – doubleInput
On entry: the residual degrees of freedom, .
c – const doubleInput
: the strictly lower triangular part of c
must contain the standard errors of the differences between the means as returned by nag_anova_random (g04bbc)
and nag_anova_row_col (g04bcc)
. That is
, contains the standard error of the difference between the
th mean in tmean
, for and .
tdc – IntegerInput
: the stride separating matrix column elements in the array c
clevel – doubleInput
On entry: the required confidence level for the computed intervals, .
cil – doubleOutput
contains the lower limit to the confidence interval for the difference between
th means in tmean
ciu – doubleOutput
contains the upper limit to the confidence interval for the difference between
th means in tmean
isig – IntegerOutput
indicates if the difference between
th means in tmean
is significant, for
. If the difference is significant then the returned value is 1; otherwise the returned value is 0.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, while . These arguments must satisfy .
On entry, .
Constraint: , for and .
Dynamic memory allocation failed.
On entry, argument type
had an illegal value.
On entry, .
An internal error has occurred in this function. Check the function call
and any array sizes. If the call is correct then please contact NAG
On entry, .
On entry, rdf
must not be less than 1.0:
There has been a failure in the computation of the studentized range statistic. Try using a smaller value of clevel
For the accuracy of the percentage point statistics see nag_deviates_students_t (g01fbc)
8 Parallelism and Performance
An alternative approach to one used in nag_anova_confid_interval (g04dbc) is the sequential testing of the Student–Newman–Keuls procedure. This, in effect, uses the Tukey–Kramer method but first ordering the treatment means and examining only subsets of the treatment means in which the largest and smallest are significantly different. At each stage the third argument of the Studentized range statistic is the number of means in the subset rather than the total number of means.
In the example taken from Winer (1970)
a completely randomized design with unequal treatment replication is analysed using nag_anova_random (g04bbc)
and then confidence intervals are computed by nag_anova_confid_interval (g04dbc) using the Tukey–Kramer method.
10.1 Program Text
Program Text (g04dbce.c)
10.2 Program Data
Program Data (g04dbce.d)
10.3 Program Results
Program Results (g04dbce.r)