multiple_comparisons
Performs multiple comparisons of means using one of Student-Newman-Keuls, LSD, Bonferroni, or Tukey’s procedures.
Synopsis
#include <imsls.h>
int *imsls_f_multiple_comparisons (int n_groups, float means[], int df, float std_error, …, 0)
The type double function is imsls_d_multiple_comparisons.
Required Arguments
int n_groups (Input)
Number of groups i.e., means, being compared.
float means[] (Input)
Array of length n_groups containing the means.
int df (Input)
Degrees of freedom associated with std_error.
float std_error (Input)
Effective estimated standard error of a mean. In fixed effects models, std_error equals the estimated standard error of a mean. For example, in a one-way model
where s2 is the estimate of σ2 and n is the number of responses in a sample mean. In models with random components, use
where sedif is the estimated standard error of the difference of two means.
Return Value
Pointer to the array of length n_groups - 1 indicating the size of the groups of means declared to be equal. Value equal_means [I] = J indicates the I-th smallest mean and the next J - 1 larger means are declared equal. Value equal_means [I] = 0 indicates no group of means starts with the I-th smallest mean.
Synopsis with Optional Arguments
#include <imsls.h>
int *imsls_f_multiple_comparisons (int n_groups, float means [], int df, float std_error,
IMSLS_ALPHA, float alpha,
IMSLS_SNK, or
IMSLS_LSD, or
IMSLS_TUKEY, or
IMSLS_BONFERRONI,
IMSLS_RETURN_USER, int *equal_means,
0)
Optional Arguments
IMSLS_ALPHA, float alpha (Input)
Significance level of test. Argument alpha must be in the interval [0.01, 0.10].
Default: alpha = 0.01
IMSLS_RETURN_USER, int *equal_means (Output)
If specified, equal_means is an array of length n_groups - 1 specified by the user. On return, equal_means contains the size of the groups of means declared to be equal. Value equal_means [I] = J indicates the i‑th smallest mean and the next J - 1 larger means are declared equal. Value equal_means [I] = 0 indicates no group of means starts with the i‑th smallest mean.
IMSLS_SNK
or
IMSLS_LSD
or
IMSLS_TUKEY
or
IMSLS_BONFERRONI
Argument | Method |
---|
IMSLS_SNK | Student-Newman-Keuls (default) |
IMSLS_LSD | Least significant difference |
IMSLS_TUKEY | Tukey’s w-procedure, also called the honestly significant difference procedure. |
IMSLS_BONFERRONI | Bonferroni t statistic |
Description
Function imsls_f_multiple_comparisons performs a multiple comparison analysis of means using one of Student-Newman-Keuls, LSD, Bonferroni, or Tukey’s procedures. The null hypothesis is equality of all possible ordered subsets of a set of means. The methods are discussed in many elementary statistics texts, e.g., Kirk (1982, pp. 123–125).
The output consists of an array of n_groups –1 integers that describe grouping of means that are considered not statistically significantly different.
For example, if n_groups=4 and the returned array is equal to {0, 2, 2} then we conclude that:
1. The smallest mean is significantly different from the others.
2. The second and third smallest means are not significantly different from one another.
3. The second and fourth means are significantly different.
4. The third and fourth means are not significantly different from one another.
These relationships can be depicted graphically as three groups of means:
Smallest Mean | Group 1 | Group 2 | Group 3 |
---|
1 | x | | |
2 | | x | |
3 | | x | x |
4 | | | x |
Examples
Example 1
A multiple-comparisons analysis is performed using data discussed by Kirk (1982, pp. 123-125). The results show that there are three groups of means with three separate sets of values: (36.7, 40.3, 43.4), (40.3, 43.4, 47.2), and (43.4, 47.2, 48.7).
In this case, the ordered means are {36.7, 40.3, 43.4, 47.2, 48.7} corresponding to treatments {1, 5, 3, 4, 2}. Since the output table is:
we can say that within each of these three groups, means are not significantly different from one another.
Treatment | Mean | Group 1 | Group 2 | Group 3 |
---|
1 | 36.7 | x | | |
5 | 40.3 | x | x | |
3 | 43.4 | x | x | x |
4 | 47.2 | | x | x |
2 | 48.7 | | | x |
#include <imsls.h>
int main ()
{
int n_groups = 5;
int df = 45;
float std_error = 1.6970563;
float means[5] = {36.7, 48.7, 43.4, 47.2, 40.3};
int *equal_means;
/* Perform multiple comparisons tests */
equal_means = imsls_f_multiple_comparisons(n_groups, means, df,
std_error, 0);
/* Print results */
imsls_i_write_matrix("Size of Groups of Means", 1, n_groups-1,
equal_means, 0);
}
Output
Size of Groups of Means
1 2 3 4
3 3 3 0
Example 2
This example uses the same data as the previous example but also uses additional methods by specifying optional arguments.
Example 2 uses the same data as Example 1: Ordered treatment means correspond to treatment order {1,5,3,4,2}.
The table produced for Bonferroni is:
Thus, these are two groups of similar means.
Treatment | Mean | Group 1 | Group 2 |
---|
1 | 36.7 | x | |
5 | 40.3 | x | x |
3 | 43.4 | x | x |
4 | 47.2 | | x |
2 | 48.7 | | x |
#include <imsls.h>
int main()
{
int n_groups = 5;
int df = 45;
float std_error = 1.6970563;
float means[5] = {36.7, 48.7, 43.4, 47.2, 40.3};
int equal_means[4];
/* Student-Newman-Keuls */
imsls_f_multiple_comparisons(n_groups, means, df, std_error,
IMSLS_RETURN_USER, equal_means,
0);
imsls_i_write_matrix("SNK ", 1, n_groups-1, equal_means,
0);
/* Bonferroni */
imsls_f_multiple_comparisons(n_groups, means, df, std_error,
IMSLS_BONFERRONI,
IMSLS_RETURN_USER, equal_means,
0);
imsls_i_write_matrix("Bonferonni ", 1, n_groups-1, equal_means,
0);
/* Least Significant Difference */
imsls_f_multiple_comparisons(n_groups, means, df, std_error,
IMSLS_LSD,
IMSLS_RETURN_USER, equal_means,
0);
imsls_i_write_matrix("LSD ", 1, n_groups-1, equal_means,
0);
/* Tukey's */
imsls_f_multiple_comparisons(n_groups, means, df, std_error,
IMSLS_TUKEY,
IMSLS_RETURN_USER, equal_means,
0);
imsls_i_write_matrix("Tukey ", 1, n_groups-1, equal_means,
0);
}
Output
SNK
1 2 3 4
3 3 3 0
Bonferonni
1 2 3 4
3 4 0 0
LSD
1 2 3 4
2 2 3 0
Tukey
1 2 3 4
3 3 3 0