# NAG CL Interfaceg04dbc (confidence)

## 1Purpose

g04dbc computes simultaneous confidence intervals for the differences between means. It is intended for use after g04bbc or g04bcc.

## 2Specification

 #include
 void g04dbc (Nag_IntervalType type, Integer nt, const double tmean[], double rdf, const double c[], Integer tdc, double clevel, double cil[], double ciu[], Integer isig[], NagError *fail)
The function may be called by the names: g04dbc, nag_anova_confidence or nag_anova_confid_interval.

## 3Description

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), ${\stackrel{^}{\sigma }}^{2}$, the residual degrees of freedom, $\nu$, 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\left(t-1\right)/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 five percent significance level then the type 1 error for all $k=t\left(t-1\right)/2$ tests will be much higher. If the tests were independent then if each test is carried out at the $100\alpha$ percent level then the overall type 1 error would be ${\alpha }^{*}=1-{\left(1-\alpha \right)}^{k}\simeq k\alpha$. In order to provide an overall protection the individual tests, or confidence intervals, would have to be carried out at a value of $\alpha$ such that ${\alpha }^{*}$ is the required significance level, e.g., five percent.
The $100\left(1-\alpha \right)$ percent confidence interval for the difference in two treatment means, ${\stackrel{^}{\tau }}_{i}$ and ${\stackrel{^}{\tau }}_{j}$ is given by
 $τ ^ i - τ ^ j ± T α,ν,t * se τ ^ i - τ ^ j ,$
where $se\left(\right)$ denotes the standard error of the difference in means and ${T}_{\left(\alpha ,\nu ,t\right)}^{*}$ is an appropriate percentage point from a distribution. There are several possible choices for ${T}_{\left(\alpha ,\nu ,t\right)}^{*}$. These are:
1. (a)$\frac{1}{2}{q}_{\left(1-\alpha ,\nu ,t\right)}$, 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.
2. (b)${t}_{\left(\alpha /k,\nu \right)}$, this is the Bonferroni method.
3. (c)${t}_{\left({\alpha }_{0},\nu \right)}$, where ${\alpha }_{0}=1-{\left(1-\alpha \right)}^{1/k}$, this is known as the Dunn–Sidak method.
4. (d)${t}_{\left(\alpha ,\nu \right)}$, 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)$\sqrt{\left(k-1\right){F}_{1-\alpha ,k-1,\nu }}$ where ${F}_{1-\alpha ,k-1,\nu }$ is the deviate corresponding to a lower tail probability of $1-\alpha$ from an $F$-distribution with $k-1$ and $\nu$ degrees of freedom. This is Scheffe's method.
In cases (b), (c) and (d), ${t}_{\left(\alpha ,\nu \right)}$ denotes the $\alpha$ two-tail significance level for the Student's $t$-distribution with $\nu$ degrees of freedom, see 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,
 $τ ^ i - τ ^ j se τ ^ i - τ ^ j$
is compared with the appropriate value of ${T}_{\left(\alpha ,\nu ,t\right)}^{*}$.

## 4References

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

## 5Arguments

1: $\mathbf{type}$Nag_IntervalType Input
On entry: indicates which method is to be used.
${\mathbf{type}}=\mathrm{Nag_TukeyInterval}$
The Tukey–Kramer method is used.
${\mathbf{type}}=\mathrm{Nag_BonferroniInterval}$
The Bonferroni method is used.
${\mathbf{type}}=\mathrm{Nag_DunnInterval}$
The Dunn–Sidak method is used.
${\mathbf{type}}=\mathrm{Nag_FisherInterval}$
The Fisher LSD method is used.
${\mathbf{type}}=\mathrm{Nag_ScheffeInterval}$
The Scheffe's method is used.
Constraint: ${\mathbf{type}}=\mathrm{Nag_TukeyInterval}$, $\mathrm{Nag_BonferroniInterval}$, $\mathrm{Nag_DunnInterval}$, $\mathrm{Nag_FisherInterval}$ or $\mathrm{Nag_ScheffeInterval}$.
2: $\mathbf{nt}$Integer Input
On entry: the number of treatment means, $t$.
Constraint: ${\mathbf{nt}}\ge 2$.
3: $\mathbf{tmean}\left[{\mathbf{nt}}\right]$const double Input
On entry: ${\mathbf{tmean}}\left[i-1\right]$ contains the treatment means, ${\stackrel{^}{\tau }}_{i}$, $i=1,2,\dots ,t$.
4: $\mathbf{rdf}$double Input
On entry: the residual degrees of freedom, $\nu$.
Constraint: ${\mathbf{rdf}}\ge 1.0$.
5: $\mathbf{c}\left[{\mathbf{nt}}×{\mathbf{tdc}}\right]$const double Input
On entry: the strictly lower triangular part of c must contain the standard errors of the differences between the means as returned by g04bbc and g04bcc. That is ${\mathbf{c}}\left[\left(i-1\right)×{\mathbf{tdc}}+j-1\right]$, $i>j$, contains the standard error of the difference between the $i$th and $j$th mean in tmean.
Constraint: ${\mathbf{c}}\left[\left(\mathit{i}-1\right)×{\mathbf{tdc}}+\mathit{j}-1\right]>0.0$, for $\mathit{i}=2,3,\dots ,t$ and $\mathit{j}=1,2,\dots ,i-1$.
6: $\mathbf{tdc}$Integer Input
On entry: the stride separating matrix column elements in the array c.
Constraint: ${\mathbf{tdc}}\ge {\mathbf{nt}}$.
7: $\mathbf{clevel}$double Input
On entry: the required confidence level for the computed intervals, $\left(1-\alpha \right)$.
Constraint: $0.0<{\mathbf{clevel}}<1.0$.
8: $\mathbf{cil}\left[{\mathbf{nt}}×\left({\mathbf{nt}}-1\right)/2\right]$double Output
On exit: ${\mathbf{cil}}\left[\left(\mathit{i}-1\right)\left(\mathit{i}-2\right)/2+\mathit{j}-1\right]$ contains the lower limit to the confidence interval for the difference between $\mathit{i}$th and $\mathit{j}$th means in tmean, for $\mathit{i}=2,3,\dots ,t$ and $\mathit{j}=1,2,\dots ,\mathit{i}-1$.
9: $\mathbf{ciu}\left[{\mathbf{nt}}×\left({\mathbf{nt}}-1\right)/2\right]$double Output
On exit: ${\mathbf{ciu}}\left[\left(\mathit{i}-1\right)\left(\mathit{i}-2\right)/2+\mathit{j}-1\right]$ contains the upper limit to the confidence interval for the difference between $\mathit{i}$th and $\mathit{j}$th means in tmean, for $\mathit{i}=2,3,\dots ,t$ and $\mathit{j}=1,2,\dots ,\mathit{i}-1$.
10: $\mathbf{isig}\left[{\mathbf{nt}}×\left({\mathbf{nt}}-1\right)/2\right]$Integer Output
On exit: ${\mathbf{isig}}\left[\left(\mathit{i}-1\right)\left(\mathit{i}-2\right)/2+\mathit{j}-1\right]$ indicates if the difference between $\mathit{i}$th and $\mathit{j}$th means in tmean is significant, for $\mathit{i}=2,3,\dots ,t$ and $\mathit{j}=1,2,\dots ,\mathit{i}-1$. If the difference is significant then the returned value is 1; otherwise the returned value is 0.
11: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tdc}}=〈\mathit{\text{value}}〉$ while ${\mathbf{nt}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdc}}\ge {\mathbf{nt}}$.
NE_2D_REAL_ARRAY_CONS
On entry, ${\mathbf{c}}\left[\left(〈\mathit{\text{value}}〉\right)×{\mathbf{tdc}}+〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{c}}\left[\left(\mathit{i}\right)×{\mathbf{tdc}}+\mathit{j}\right]>0.0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nt}}-1$ and $\mathit{j}=0,1,\dots ,i-1$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument type had an illegal value.
NE_INT_ARG_LT
On entry, ${\mathbf{nt}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nt}}\ge 2$.
NE_INTERNAL_ERROR
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 for assistance.
NE_REAL
On entry, ${\mathbf{clevel}}=〈\mathit{\text{value}}〉$.
Constraint: $0.0<{\mathbf{clevel}}<1.0$.
NE_REAL_ARG_LT
On entry, rdf must not be less than 1.0: ${\mathbf{rdf}}=〈\mathit{\text{value}}〉$.
NE_STUDENTIZED_STAT
There has been a failure in the computation of the studentized range statistic. Try using a smaller value of clevel.

## 7Accuracy

For the accuracy of the percentage point statistics see g01fbc.

## 8Parallelism and Performance

g04dbc is not threaded in any implementation.

An alternative approach to one used in 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.

## 10Example

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

### 10.1Program Text

Program Text (g04dbce.c)

### 10.2Program Data

Program Data (g04dbce.d)

### 10.3Program Results

Program Results (g04dbce.r)