NAG FL Interface
g04dbf (confidence)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g04dbf computes simultaneous confidence intervals for the differences between means. It is intended for use after g04bbf or g04bcf.

2 Specification

Fortran Interface
Subroutine g04dbf ( typ, nt, tmean, rdf, c, ldc, clevel, cil, ciu, isig, ifail)
Integer, Intent (In) :: nt, ldc
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: isig(nt*(nt-1)/2)
Real (Kind=nag_wp), Intent (In) :: tmean(nt), rdf, c(ldc,nt), clevel
Real (Kind=nag_wp), Intent (Out) :: cil(nt*(nt-1)/2), ciu(nt*(nt-1)/2)
Character (1), Intent (In) :: typ
C Header Interface
#include <nag.h>
void  g04dbf_ (const char *typ, const Integer *nt, const double tmean[], const double *rdf, const double c[], const Integer *ldc, const double *clevel, double cil[], double ciu[], Integer isig[], Integer *ifail, const Charlen length_typ)
The routine may be called by the names g04dbf or nagf_anova_confidence.

3 Description

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), σ^2, the residual degrees of freedom, ν, and the (variance ratio) F-statistic for the t 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 t treatments then there are t(t-1)/2 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 t-test is used with, say, a 6% significance level then the type 1 error for all k=t(t-1)/2 tests will be much higher. If the tests were independent then if each test is carried out at the 100α percent level then the overall type 1 error would be α*=1-(1-α)kkα. 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.
The 100(1-α) percent confidence interval for the difference in two treatment means, τ^i and τ^j is given by
(τ^i-τ^j)±T(α,ν,t)*se(τ^i-τ^j),  
where se() denotes the standard error of the difference in means and T(α,ν,t)* is an appropriate percentage point from a distribution. There are several possible choices for T(α,ν,t)*. These are:
  1. (a)12q(1-α,ν,t), the studentized range statistic, see g01fmf. It is the appropriate statistic to compare the largest mean with the smallest mean. This is known as Tukey–Kramer method.
  2. (b)t(α/k,ν), this is the Bonferroni method.
  3. (c)t(α0,ν), where α0=1-(1-α)1/k, this is known as the Dunn–Sidak method.
  4. (d)t(α,ν), this is known as Fisher's LSD (least significant difference) method. It should only be used if the overall F-test is significant, the number of treatment comparisons is small and were planned before the analysis.
  5. (e)(k-1)F1-α,k-1,ν where F1-α,k-1,ν is the deviate corresponding to a lower tail probability of 1-α from an F-distribution with k-1 and ν degrees of freedom. This is Scheffe's method.
In cases (b), (c) and (d), t(α,ν) denotes the α two tail significance level for the Student's t-distribution with ν degrees of freedom, see g01fbf.
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,
τ^i-τ^j se(τ^i-τ^j)  
is compared with the appropriate value of T(α,ν,t)*.

4 References

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

5 Arguments

1: typ Character(1) Input
On entry: indicates which method is to be used.
typ='T'
The Tukey–Kramer method is used.
typ='B'
The Bonferroni method is used.
typ='D'
The Dunn–Sidak method is used.
typ='L'
The Fisher LSD method is used.
typ='S'
The Scheffe's method is used.
Constraint: typ='T', 'B', 'D', 'L' or 'S'.
2: nt Integer Input
On entry: t, the number of treatment means.
Constraint: nt2.
3: tmean(nt) Real (Kind=nag_wp) array Input
On entry: the treatment means, τ^i, for i=1,2,,t.
4: rdf Real (Kind=nag_wp) Input
On entry: ν, the residual degrees of freedom.
Constraint: rdf1.0.
5: c(ldc,nt) Real (Kind=nag_wp) array Input
On entry: the strictly lower triangular part of c must contain the standard errors of the differences between the means as returned by g04bbf and g04bcf. That is c(i,j), i>j, contains the standard error of the difference between the ith and jth mean in tmean.
Constraint: c(i,j)>0.0, for i=2,3,,t and j=1,2,,i-1.
6: ldc Integer Input
On entry: the first dimension of the array c as declared in the (sub)program from which g04dbf is called.
Constraint: ldcnt.
7: clevel Real (Kind=nag_wp) Input
On entry: the required confidence level for the computed intervals, (1-α).
Constraint: 0.0<clevel<1.0.
8: cil(nt×(nt-1)/2) Real (Kind=nag_wp) array Output
On exit: the ((i-1)(i-2)/2+j) th element contains the lower limit to the confidence interval for the difference between ith and jth means in tmean, for i=2,3,,t and j=1,2,,i-1.
9: ciu(nt×(nt-1)/2) Real (Kind=nag_wp) array Output
On exit: the ((i-1)(i-2)/2+j) th element contains the upper limit to the confidence interval for the difference between ith and jth means in tmean, for i=2,3,,t and j=1,2,,i-1.
10: isig(nt×(nt-1)/2) Integer array Output
On exit: the ((i-1)(i-2)/2+j) th element indicates if the difference between ith and jth means in tmean is significant, for i=2,3,,t and j=1,2,,i-1. If the difference is significant then the returned value is 1; otherwise the returned value is 0.
11: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, clevel=value.
Constraint: 0.0<clevel<1.0.
On entry, ldc=value and nt=value.
Constraint: ldcnt.
On entry, nt=value.
Constraint: nt2.
On entry, rdf=value.
Constraint: rdf1.0.
On entry, typ=value.
Constraint: typ='T', 'B', 'D', 'L' or 'S'.
ifail=2
On entry, i=value and j=value.
Constraint: c(i,j)>0.0.
ifail=3
There has been a failure in the computation of the studentized range statistic. This is an unlikely error exit. Try using a small value of clevel.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

For the accuracy of the percentage point statistics see g01fbf and g01fmf.

8 Parallelism and Performance

g04dbf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

If the treatments have a structure then the use of linear contrasts as computed by g04daf may be more appropriate.
An alternative approach to one used in g04dbf 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 parameter of the Studentized range statistic is the number of means in the subset rather than the total number of means.

10 Example

In the example taken from Winer (1970) a completely randomized design with unequal treatment replication is analysed using g04bbf and then confidence intervals are computed by g04dbf using the Tukey–Kramer method.

10.1 Program Text

Program Text (g04dbfe.f90)

10.2 Program Data

Program Data (g04dbfe.d)

10.3 Program Results

Program Results (g04dbfe.r)