Two-by-two ANOVA : Global and Graphical Comparisons Based on an Extension of the Shift Function

When comparing two independent groups, the shift function compares all of the quantiles in a manner that controls the probability of at least one Type I error, assuming random sampling only. Moreover, it provides a much more detailed sense of how groups compare, versus using a single measure of location, and the associated plot of the data can yield valuable insights. This note examines the small-sample properties of an extension of the shift function where the goal is to compare the distributions of two specified linear sums of the random variables under study, with an emphasis on a two-by-two design. A very simple method controls the probability of a Type I error. Moreover, very little power is lost versus comparing means when sampling is from normal distributions with equal variances.


Introduction
The Doksum and Sievers (1976) shift function provides a global and detailed description of how the distributions, corresponding to two independent random variables, compare.It does this via confidence intervals for the differences between all of the quantiles, and the resulting plot can reveal information that is completely missed when attention is restricted to a single measure of location.The method is distribution free in the sense that the simultaneous probability coverage over all quantiles can be determined exactly assuming random sampling only.Moreover, in the event sampling is from normal distributions that differ in location only, its power compares reasonably well with Student's t.And under general conditions it can have higher power than any method based on a single measure of location simply because it is sensitive to broader range of features associated with the distributions under study.
The primary goal of this note is to consider an extension of the shift function to a two-by-two ANOVA design.Let X 1 and X 2 be the random variables associated with the first level of the first factor.And let X 3 and X 4 be the random variables associated with the second level of the first factor.Consider Y 1 = (X 1 + X 2 )/2 and Y 2 = (X 3 + X 4 )/2,and let F 1 and F 2 be the corresponding distributions.Then an approach to understanding how the levels of the first factor differ is to investigate in detail how F 1 compares to F 2 .Of course, an analog of interactions could be studied as well where now Before continuing, an illustration of the shift function, as it is currently used, might help motivate this paper.Victoroff et al. (2006) were generally interested in both psychological and physiological measures related to terrorism.In one portion of the study, which dealt with measures of depression among 14-year-old boys living in Gaza, the goal was to compare two groups of individuals: those who had a family member wounded or killed by Israelis, and those who had not.The solid line in Figure 1 shows the estimated difference between the quantiles, where the x-axis is the measure of depression for the first group (a family member has not been killed or wounded).The circle indicates the sample median for the first group and the upper and lower quartiles are marked by a +.The dashed lines form an approximate .95confidence band for the difference of all quantiles.(The exact simultaneous probability coverage can be determined, assuming random sampling only, and is .98.)This graph indicates that when comparing individuals with relatively low measures of depression, there is relatively little difference, but as we move toward situations where measures of depression are higher, the difference between the groups becomes more pronounced.(Note that if the groups differ in location only, the shift function would be a straight horizontal line.)In particular, the hypothesis of equal quantiles is rejected for the quantiles extending from .69 to .90.
It seems evident that the Doksum-Sievers method can make a practical difference versus using a single measure of location to compare groups.Consequently, it is only natural to consider how the method might be applied when dealing with a two-way design.

Review of the Doksum-Sievers Shift Function
This section reviews the technical details associated with the shift function that will be needed here.Let G 1 and G 2 be the distributions associated with the independent random variables X 1 and X 2 , respectively.Let x 1q and x 2q be the corresponding q-th quantiles.The shift function is Let Ĝj (x) be the usual empirical distribution associated with the j-th group, based on a random sample of size n j , and let be the two-sample Kolmogorov-Smirnov test statistic, where M = n 1 n 2 /N and N = n 1 + n 2 .Consider the null hypothesis and when H 0 is true, suppose c satisfies Doskum and Sievers (1976, p. 423) show that, because where Switzer, 1976.)This band is called an S band.
Given c, the exact value of P (T ( Ĝ1 , Ĝ2 ) ≤ c) can be determined using the recursive method in Kim and Jennrich (1973) when tied values occur with probability zero.When tied values can occur, results in Schroër and Trenkler (1995) can be used to determine P (T ( Ĝ1 , Ĝ2 ) ≤ c).
Following Doksum and Sievers, the method can be implemented as follows.Let X ij (i = 1, . . ., n j ) be a random sample of size n j from the jth group.Denote the order statistics for the jth group by where the notation < x > means to round up to the nearest integer.Let where [x] means that x is rounded down to the nearest integer.Then a level 1−α simultaneous, distribution-free confidence band for ∆ where

Description of the Proposed Extension
The focus is on J = 4 independent groups, but comments regarding the more general case where J > 4 will be made.Let X j be some random variable associated with the jth group (j = 1, . . ., 4).Let and let F k be the distribution of Y k (k = 1, 2).One goal might be to test versus F 1 (y) = F 2 (y) for some y.But if this null hypothesis is rejected, perhaps a more important goal is to determine where the distributions differ and by how much using an obvious extension of the the shift function: Let X ij (i = 1, . . ., n j ) be a random sample of size n j from the jth group, let For convenience, the n 1 n 2 B ik1 values are written as V 1 ( = 1, . . ., n 1 n 2 ) and V 2 is defined in the same manner using the B ik2 values.Also set Let Fj be the empirical distribution associated with the V j values and let Then an extension of the shift function to the situation at hand is achieved if now c can be determined such that A fundamental obstacle to determining P (W ≤ c) is that among the N 1 V 1 variables, some are dependent, and of course the same is true for the V 2 variables.Consequently, the recursive algorithm derived by Kim and Jennrich (1973) for determining P (T ( Ĝ1 , Ĝ2 ) ≤ c) does not extend to the situation at hand.And if this issue is ignored, it is readily verified (via simulations) that the actual probability coverage can differ substantially from the nominal level.But there is a simple solution: Use simulations to determine c so that under normality, equation ( 2) is approximately true.(This is readily done with modern computers and software for accomplishing this goal is described and illustrated in section 5.) Note that T ( Ĝ1 , Ĝ2 ) is invariant under order-preserving transformations of the data, but this is not quite the case when using W .So the strategy is to to generate n j values from a standard normal distribution for the jth group, compute W , and repeat this say I times.Letting W (1) ≤ • • • ≤ W (I) be the resulting W values written in ascending order, choose c to be W (d) , where d = (1−α)I rounded to the nearest integer.Here I = 1000 is used.Simulations reported in section 4 indicate that for non-normal distributions that represent a seemingly extreme departure from normality, the actual probability of a Type I error remains fairly close to the nominal level.The same is true for the discrete distributions to be considered.

The case J > 4
In principle, the method just described can be extended to J > 4 groups, where primarily for convenience, J even is assumed.Let K = J/2.consider, for example, It is evident that this approach becomes impractical because estimating the distribution of B 1 , for example, would require computing n 1 n 2 . . ., n K terms, which soon becomes too large.To get at least an approximate solution, one possibility would be to use a sample of size L of the n 1 < n 2 < • • • < n K combinations and estimate the distribution of B 1 for each of the L 1 combinations, and of course the same could be done when dealing with B 2 .Here, L 1 = n (K−1) n (K) is used, where n (1) , ≤ n (K) and L 2 is defined likewise.

Some simulation results
If the goal is to have the probability of at least one Type I error equal to .05,say, when applying the shift function, under general conditions this cannot be achieved exactly because the distribution of the test statistic is discrete.That is, the exact probability of at least one Type I error can be determined, given a critical value c, but choosing c so that the probability of at least one Type I error equal to .05,say, is impossible.So one goal here is to check on how close the actual probability of at least one Type I error is to .05 using the approximation of the critical value previously described.Because W is not quite invariant under monotone increasing transformations of the data, another goal is to check the level of the test when sampling from some non-normal distributions.Yet another goal is to determine how much power is lost versus comparing means under normality and homoscedasticity.
First consider the case n 1 = n 2 = n 3 = n 4 = 10 and suppose the goal is to test the hypothesis of no interactions.(The same results are obtained when dealing with main effects.)To begin, observations are sampled from standard normal distributions.Then based on simulations with 2000 iterations, the actual probability of at least one Type I error is .046.Increasing the sample sizes to 20, the estimate is now .051.
As a check on the effects of sampling from non-normal distributions, observations were generated from g-and-h distributions (Hoaglin, 1985).If Z has a standard normal distribution, then has a g-and-h distribution where g and h are parameters that determine the first four moments.In addition to normal distributions (g = h = 0), simulations were run with a symmetric heavy-tailed distribution (h = .5,g = 0), an asymmetric distribution with relatively light tails (h = .5,g = 0), and an asymmetric distribution with heavy tails (g = h = .5).Table 1 summarizes the skewness (κ 1 ) and kurtosis (κ 2 ) of these four distributions.Note that h = .5represents a seemingly extreme departure from normality because now kurtosis is not even defined.And with g = h = .5,skewness is not defined.Here, equal sample sizes of 10, 20 and 100 were used, plus a situation where the first two groups have sample sizes of 10 and the other two have sample sizes of 100.The estimated probability of a Type I error, among all conditions considered, ranged between .046 and .058.The highest estimate corresponds to where unequal sample sizes are used and sampling is from an asymmetric distribution with heavy tails (g = h = .5).With equal sample sizes the largest estimate was .056.
Table 1: Some properties of the g-and-h distribution g h κ 1 κ 2 0.0 0.0 0.00 3.0 0.0 0.5 0.00 -0.5 0.0 1.75 8.9 0.5 0.5 -- A related issue is how tied values affect the probability of a Type I error.To get at least some indication, observations were generated from the binomial distribution 10 x .3x .7 10−x .
With n 1 = n 2 = n 3 = n 4 = 10, now the probability of at least one Type I error was estimated to be .041.As for power, consider again the situation where data are generated from a normal distribution with δ = .8added to every observation in the first group.The usual ANOVA F test has power .44 when testing at the .05level.The heteroscedastic method for means derived by Johansen (1980) has power .42,and the extension of the shift function has power .41.Let Φ denote a standard normal cumulative distribution function.If instead sampling is from the contaminated normal distribution .9Φ(x) + .1Φ(x/10),which has heavy tails, and if now δ = 2, power for the ANOVA F, Johansen's method and the shift function is now .35,.50 and .93,respectively.Now consider the case of a two-by-four design where the goal is to test the hypothesis of no main effects for the first factor.In this case, only a subset of all possible combinations of the data are used and an issue is whether this has a major impact, under normality, on power versus ANOVA methods based on means.If now δ = 1.2, with all sample sizes equal to 20 and again testing at the .05level, power for the ANOVA F, Johansen's method and the shift function is now .5, .5 and .42,respectively.For a two-by-five design, now power is .38,.38 and .32.For this latter case, if sampling is from the contaminated normal, power is now .07,.08 and .17.Increasing δ to 2, the power estimates are .12,.13,and .37.

More Comments and Illustrations
R software for applying the method in this paper is available from the author.For convenience functions specifically designed for a two-by-two design are included.They are the functions Aband, intended to examine main effects for the first factor, Bband, which deals with main effects for the second factor, and iband, which deals with interactions.For the more general case where the goal is to compare any two linear contrasts, the function sintcon can be used.
Note that the extensions of the shift function provide a graphical check on the nature of any differences among the groups.If groups differ in location only, the resulting plots should yield two straight, horizontal lines.If the groups differ in both location and scale, again we get straight lines, but now they are not horizontal.And if the groups differ in terms of skewness, the plotted lines will be curved.
Also note that when testing the hypothesis of no interaction, the resulting plot created by the function iband provides no information about the extent to which the interaction is disordinal.One way of dealing with this, when dealing with a two-by-two design, is to plot two shift functions.The first might be the plot associated with the two groups corresponding to the first level of the first factor, and the other would be the plot associated with the second level of the first factor.If there is no disordinal interaction, the plots should be identical.The function disband, also available from the author, can be used to create this plot.
To illustrate some of these features, first consider an artificial situation where n = 80 for each of four groups (a two-by-two design), the first group has a lognormal distribution, shifted to have a median of zero, two groups have a standard normal distribution, and the fourth has a normal distribution with mean 0 and standard deviation 2. The upper-left panel of Figure 2 shows the resulting plot when examining interactions (with the R function iband).The upper-right panel is the output from disband using the same data.The two shift functions differ, suggesting a disordinal interaction, and the graph reflects the additional fact that the magnitude of the differences increases as we move from low to high values.The lower-left panel is based on data stemming from a study dealing with weight gain associated with four types of diet.The two factors were source of protein (beef versus cereal) and amount of protein (high versus low).Shown is a shift function for the difference between the first two levels versus the second two (using the function iband).An interaction is found, and because the plot is approximately a straight horizontal line, it suggests that the interaction consists essentially of a change in location only.But this plot does not reveal any information about the extent to which the interaction is disordinal.To deal with this issue, a shift function for both high versus low protein when the source of protein is beef, as well as a shift function of high versus low when the source of protein is cereal, is shown in the lower-right panel (using the function disband).As can be seen, the two shift functions differ, consistent with a disordinal interaction, and the nature of the differences appears to be primarily shifts in location.

Concluding Remarks
As a final note, it would be of interest to extend the method in this paper to dependent groups.Perhaps some extension of the method in Lombard (2005) could be used, but this remains to be determined.

Figure 1 :
Figure 1 Figure 1: A plot of the shift function for the depression data.

Figure 2 :
Figure 2: Plots based on the R functions iband and disband that provide details about interactions.