Integer type:** int32**** int64**** nag_int** show int32 show int32 show int64 show int64 show nag_int show nag_int

nag_anova_confidence (g04db) computes simultaneous confidence intervals for the differences between means. It is intended for use after nag_anova_random (g04bb) or nag_anova_rowcol (g04bc).

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}${\hat{\sigma}}^{2}$, the residual degrees of freedom, ν$\nu $, and the (variance ratio) F$F$-statistic for the t$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$t$ treatments then there are t(t − 1) / 2$t(t-1)/2$ comparisons to be considered. In tests the type 1$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$t$-test is used with, say, a 6%$6\%$ significance level then the type 1$1$ error for all k = t(t − 1) / 2$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α$100\alpha $ percent level then the overall type 1$1$ error would be α^{*} = 1 − (1 − α)^{k} ≃ kα${\alpha}^{*}=1-{(1-\alpha )}^{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(1 − α)$100(1-\alpha )$ percent confidence interval for the difference in two treatment means, τ̂_{i}${\hat{\tau}}_{i}$ and τ̂_{j}${\hat{\tau}}_{j}$ is given by

where se()$se\left(\right)$ denotes the standard error of the difference in means and T_{(α,ν,t)}^{ * }${T}_{(\alpha ,\nu ,t)}^{*}$ is an appropriate percentage point from a distribution. There are several possible choices for T_{(α,ν,t)}^{ * }${T}_{(\alpha ,\nu ,t)}^{*}$. These are:

(τ̂ _{i} − τ̂_{j}) ± T_{(α,ν,t)}^{ * }se(τ̂_{i} − τ̂_{j}),
$$({\hat{\tau}}_{i}-{\hat{\tau}}_{j})\pm {T}_{(\alpha ,\nu ,t)}^{*}se({\hat{\tau}}_{i}-{\hat{\tau}}_{j})\text{,}$$ |

(a) | (1/2)q_{(1 − α,ν,t)}$\frac{1}{2}{q}_{(1-\alpha ,\nu ,t)}$, the studentized range statistic, see nag_stat_inv_cdf_studentized_range (g01fm). It is the appropriate statistic to compare the largest mean with the smallest mean. This is known as Tukey–Kramer method. |

(b) | t_{(α / k,ν)}${t}_{(\alpha /k,\nu )}$, this is the Bonferroni method. |

(c) | t_{(α0,ν)}${t}_{({\alpha}_{0},\nu )}$, where α_{0} = 1 − (1 − α)^{1 / k}${\alpha}_{0}=1-{(1-\alpha )}^{1/k}$, this is known as the Dunn–Sidak method. |

(d) | t_{(α,ν)}${t}_{(\alpha ,\nu )}$, this is known as Fisher's LSD (least significant difference) method. It should only be used if the overall F$F$-test is significant, the number of treatment comparisons is small and were planned before the analysis. |

(e) | sqrt((k − 1)F_{1 − α,k − 1,ν})$\sqrt{(k-1){F}_{1-\alpha ,k-1,\nu}}$ where F_{1 − α,k − 1,ν}${F}_{1-\alpha ,k-1,\nu}$ is the deviate corresponding to a lower tail probability of 1 − α$1-\alpha $ from an F$F$-distribution with k − 1$k-1$ and ν$\nu $ degrees of freedom. This is Scheffe's method. |

In cases (b), (c) and (d), t_{(α,ν)}${t}_{(\alpha ,\nu )}$ denotes the α$\alpha $ two tail significance level for the Student's t$t$-distribution with ν$\nu $ degrees of freedom, see nag_stat_inv_cdf_students_t (g01fb).

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 T_{(α,ν,t)}^{ * }${T}_{(\alpha ,\nu ,t)}^{*}$.

(τ̂ _{i} − τ̂_{j})/(se(τ̂_{i} − τ̂_{j}))
$$\frac{{\hat{\tau}}_{i}-{\hat{\tau}}_{j}}{se({\hat{\tau}}_{i}-{\hat{\tau}}_{j})}$$ |

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

- 1: typ – string (length ≥ 1)
- Indicates which method is to be used.
- typ = 'T'${\mathbf{typ}}=\text{'T'}$
- The Tukey–Kramer method is used.
- typ = 'B'${\mathbf{typ}}=\text{'B'}$
- The Bonferroni method is used.
- typ = 'D'${\mathbf{typ}}=\text{'D'}$
- The Dunn–Sidak method is used.
- typ = 'L'${\mathbf{typ}}=\text{'L'}$
- The Fisher LSD method is used.
- typ = 'S'${\mathbf{typ}}=\text{'S'}$
- The Scheffe's method is used.

*Constraint*: typ = 'T'${\mathbf{typ}}=\text{'T'}$, 'B'$\text{'B'}$, 'D'$\text{'D'}$, 'L'$\text{'L'}$ or 'S'$\text{'S'}$. - 2: tmean(nt) – double array
- The treatment means, τ̂
_{i}${\hat{\tau}}_{\mathit{i}}$, for i = 1,2, … ,t$\mathit{i}=1,2,\dots ,t$. - 3: rdf – double scalar
- ν$\nu $, the residual degrees of freedom.
- 4: c(ldc,nt) – double array
- ldc, the first dimension of the array, must satisfy the constraint ldc ≥ nt$\mathit{ldc}\ge {\mathbf{nt}}$.The strictly lower triangular part of c must contain the standard errors of the differences between the means as returned by nag_anova_random (g04bb) and nag_anova_rowcol (g04bc). That is c(i,j)${\mathbf{c}}\left(i,j\right)$, i > j$i>j$, contains the standard error of the difference between the i$i$th and j$j$th mean in tmean.
*Constraint*: c(i,j) > 0.0${\mathbf{c}}\left(\mathit{i},\mathit{j}\right)>0.0$, for i = 2,3, … ,t$\mathit{i}=2,3,\dots ,t$ and j = 1,2, … ,i − 1$\mathit{j}=1,2,\dots ,\mathit{i}-1$. - 5: clevel – double scalar
- The required confidence level for the computed intervals, (1 − α$1-\alpha $).

- 1: nt – int64int32nag_int scalar
*Default*: The dimension of the array tmean and the first dimension of the array c and the second dimension of the array c. (An error is raised if these dimensions are not equal.)t$t$, the number of treatment means.

- ldc

- 1: cil(nt × (nt − 1) / 2${\mathbf{nt}}\times ({\mathbf{nt}}-1)/2$) – double array
- The ((i − 1)(i − 2) / 2 + j) $((\mathit{i}-1)(\mathit{i}-2)/2+\mathit{j})$th element contains the lower limit to the confidence interval for the difference between i$\mathit{i}$th and j$\mathit{j}$th means in tmean, for i = 2,3, … ,t$\mathit{i}=2,3,\dots ,t$ and j = 1,2, … ,i − 1$\mathit{j}=1,2,\dots ,\mathit{i}-1$.
- 2: ciu(nt × (nt − 1) / 2${\mathbf{nt}}\times ({\mathbf{nt}}-1)/2$) – double array
- The ((i − 1)(i − 2) / 2 + j) $((\mathit{i}-1)(\mathit{i}-2)/2+\mathit{j})$th element contains the upper limit to the confidence interval for the difference between i$\mathit{i}$th and j$\mathit{j}$th means in tmean, for i = 2,3, … ,t$\mathit{i}=2,3,\dots ,t$ and j = 1,2, … ,i − 1$\mathit{j}=1,2,\dots ,\mathit{i}-1$.
- 3: isig(nt × (nt − 1) / 2${\mathbf{nt}}\times ({\mathbf{nt}}-1)/2$) – int64int32nag_int array
- The ((i − 1)(i − 2) / 2 + j) $((\mathit{i}-1)(\mathit{i}-2)/2+\mathit{j})$th element indicates if the difference between i$\mathit{i}$th and j$\mathit{j}$th means in tmean is significant, for i = 2,3, … ,t$\mathit{i}=2,3,\dots ,t$ and j = 1,2, … ,i − 1$\mathit{j}=1,2,\dots ,\mathit{i}-1$. If the difference is significant then the returned value is 1$1$; otherwise the returned value is 0$0$.
- 4: ifail – int64int32nag_int scalar
- ifail = 0${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Errors or warnings detected by the function:

On entry, nt < 2${\mathbf{nt}}<2$, or ldc < nt$\mathit{ldc}<{\mathbf{nt}}$, or rdf < 1.0${\mathbf{rdf}}<1.0$, or clevel ≤ 0.0${\mathbf{clevel}}\le 0.0$, or clevel ≥ 1.0${\mathbf{clevel}}\ge 1.0$, or typ ≠ 'T'${\mathbf{typ}}\ne \text{'T'}$, 'B'$\text{'B'}$, 'D'$\text{'D'}$, 'L'$\text{'L'}$ or 'S'$\text{'S'}$.

On entry, c(i,j) ≤ 0.0${\mathbf{c}}\left(i,j\right)\le 0.0$ for some i,j$i,j$, i = 2,3, … ,t$i=2,3,\dots ,t$ and j = 1,2, … ,i − 1$j=1,2,\dots ,i-1$.

- There has been a failure in the computation of the studentized range statistic. This is an unlikely error. Try using a small value of clevel.

For the accuracy of the percentage point statistics see nag_stat_inv_cdf_students_t (g01fb) and nag_stat_inv_cdf_studentized_range (g01fm).

If the treatments have a structure then the use of linear contrasts as computed by nag_anova_contrasts (g04da) may be more appropriate.

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

Open in the MATLAB editor: nag_anova_confidence_example

function nag_anova_confidence_exampletyp = 'T'; tmean = [3; 7; 2.25; 9.428571428571427]; rdf = 22; c = [0.4266566766566766, -0.127997002997003, -0.127997002997003, -0.127997002997003; 1.104643877110671, 0.5375874125874126, -0.127997002997003, -0.127997002997003; 0.9852126366393904, 1.039987824604055, 0.2879932567432567, -0.127997002997003; 1.014924193896684, 1.068176883894971, 0.9441438976360614, 0.347420436706151]; clevel = 0.95; [cil, ciu, isig, ifail] = nag_anova_confidence(typ, tmean, rdf, c, clevel)

cil = 0.9326 -3.4857 -7.6378 3.6103 -0.5375 4.5569 ciu = 7.0674 1.9857 -1.8622 9.2468 5.3947 9.8003 isig = 1 0 1 1 0 1 ifail = 0

Open in the MATLAB editor: g04db_example

function g04db_exampletyp = 'T'; tmean = [3; 7; 2.25; 9.428571428571427]; rdf = 22; c = [0.4266566766566766, -0.127997002997003, -0.127997002997003, -0.127997002997003; 1.104643877110671, 0.5375874125874126, -0.127997002997003, -0.127997002997003; 0.9852126366393904, 1.039987824604055, 0.2879932567432567, -0.127997002997003; 1.014924193896684, 1.068176883894971, 0.9441438976360614, 0.347420436706151]; clevel = 0.95; [cil, ciu, isig, ifail] = g04db(typ, tmean, rdf, c, clevel)

cil = 0.9326 -3.4857 -7.6378 3.6103 -0.5375 4.5569 ciu = 7.0674 1.9857 -1.8622 9.2468 5.3947 9.8003 isig = 1 0 1 1 0 1 ifail = 0

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013