User:Ucjtsam/sandbox

In statistics the Jonckheere Trend test (sometimes called the Jonckheere-Terpstra Test) is a test for an ordered alternative hypothesis within an independent samples (between-participants) design. It is similar to the Kruskal-Wallis test in that the null hypothesis is that several independent samples are from the same population. However, with the Kruskal-Wallis test there is no a priori ordering of the populations from which the samples are drawn. When there is an a priori ordering, the Jonckheere test has more statistical power than the Kruskal-Wallis test.

The null and alternative hypotheses can be conveniently expressed in terms of population medians for k populations (where k > 2). Letting θi be the population median for the ith population, the null hypothesis is:


 * $$H_0: \theta_1 = \theta_2 = \ldots = \theta_k$$

The alternative hypothesis is that the population medians have an a priori ordering e.g.:


 * $$H_A: \theta_1 < \theta_2 < \ldots < \theta_k$$

Procedure
The test can be seen as a special case of Maurice Kendall’s more general method of rank correlation (e.g., Kendall, 1962) and make use of the Kendall’s S statistic. This can be computed in one of two ways:

The ‘Direct Counting’ Method

 * 1) Arrange the samples in the predicted order
 * 2) For each score in turn, count how many scores in the samples to the right are larger than the score in question. This is P.
 * 3) For each score in turn, count how many scores in the samples to the right are smaller than the score in question. This is Q.
 * 4) S = P – Q

The ‘Nautical’ Method

 * 1) Cast the data into an ordered contingency table, with the levels of the independent variable increasing from left to right, and values of the dependent variable increasing from top to bottom.
 * 2) For each entry in the table, count all other entries that lie to the ‘South East’ of the particular entry. This is P.
 * 3) For each entry in the table, count all other entries that lie to the ‘South West’ of the particular entry. This is Q.
 * 4) S = P – Q

Note that there will always be ties in the independent variable (individuals are ‘tied’ in the sense that they are in the same group) but there may or may not be ties in the dependent variable. If there are no ties – or the ties occur within a particular sample (which does not effect the value of the test statistic) – exact tables of S are available; for example, Jonckheere (1954) provided selected tables for values of k from 3 to 6 and equal samples sizes (m) from 2 to 5, and Siegel and Castellan (1988) combined Jonckheere’s (1954) tables with those due to Odeh (1971) to give critical values for k = 3 and ni &le; 8 and equal n's (2 &le; n &le; 6) for k = 4, 5, 6.

Normal Approximation to S
The standard normal distribution can be used to approximate the distribution of S under the null hypothesis for cases in which exact tables are not available. The mean of the distribution of S will always be zero, and assuming that there are no ties scores between the values in two (or more) different samples the variance is given by


 * $$\text{VAR}(S)=\frac{2(n^3-\sum t^3_i)+3(n^2-\sum t^2_i)}{18}$$

Where n is the total number of scores, and ti is the number of scores in the ith sample. The approximation to the standard normal distribution can be improved by the use of a continuity correction: Sc = |S| - 1. Thus 1 is subtracted from a positive S value and 1 is added to a negative S value. The z-score equivalent is then given by


 * $$z =\frac{S_c}{\sqrt{\text{VAR}(S)}}$$

Ties
If scores are tied between the values in two (or more) different samples there are no exact table for the S distribution and an approximation to the normal distribution has to be used. In this case no continuity correction is applied to the value of S and the variance is given by


 * $$\begin{align}\text{VAR}(S)=&\frac{2(n^3-\sum t^3_i -\sum u^3_i)+3(n^2-\sum t^2_i -\sum u^2_i)+5n}{18} \\

&+\frac{(\sum t^3_i-3\sum t^2_i+2n)(\sum u^3_i-3\sum u^2_i+2n)}{9n(n-1)(n-2)} \\ &+\frac{(\sum t^2_i-n)(\sum u^2_i-n)}{2n(n-1)}\end{align}$$

where ti is a row marginal total and ui a column marginal total in the contingency table. The z-score equivalent is then given by


 * $$z =\frac{S}{\sqrt{\text{VAR}(S)}}$$

A Numerical Example
In a partial replication of a study by Loftus and Palmer (1974) participants were assigned at random to one of three groups, and then shown a film of two cars crashing into each other. After viewing the film, the participants in one group were asked the following question: “About how fast were the cars going when they contacted each other?” Participants in a second group were asked, “About how fast were the cars going when they bumped into each other?” Participants in the third group were asked, “About how fast were the cars going when they smashed into each other?” Loftus and Palmer predicted that the action verb used (contacted, bumped, smashed) would influence the speed estimates in miles per hour (mph) such that action verbs implying greater energy would lead to higher estimates speeds. The follow results were obtained (simulated data):


 * {| border="1"

! scope="col" | Contacted ! scope="col" | Bumped ! scope="col" | Smashed ! 10 || 12 || 20 ! 12 || 18 || 25 ! 14 || 20 || 27 ! 16 || 22 || 30 ! mdn = 13 || mdn = 19 || mdn = 26
 * }

The ‘Direct Counting’ Method

 * The samples are already in the predicted order
 * For each score in turn, count how many scores in the samples to the right are larger than the score in question to obtain P:
 * P = 8 + 7 + 7 + 7 + 4 + 4 + 3 + 3 = 43


 * For each score in turn, count how many scores in the samples to the right are smaller than the score in question to obtain Q:
 * Q = 0 + 0 + 1 + 1 + 0 + 0 + 0 + 1 = 3


 * S = P - Q = 43 - 3
 * S = 40

The 'Nautical' Method

 * Cast the data into an ordered contingency table


 * {| border="1"

! scope="col" | mph ! scope="col" | Contacted ! scope="col" | Bumped ! scope="col" | Smashed ! scope="col" | Totals (ti) ! 10 || 1 || 0 ||0 || 1|| ! 12 || 1 || 1 ||0 || 2|| ! 14 || 1 || 0 ||0 || 1|| ! 16 || 1 || 0 ||0 || 1|| ! 18 || 0 || 1 ||0 || 1|| ! 20 || 0 || 1 ||1 || 2|| ! 22 || 0 || 1||0 || 1|| ! 25 || 0 || 0 ||1 || 1|| ! 27 || 0 || 0 ||1 || 1|| ! 30 || 0 || 0 ||1 || 1|| ! Totals (ui) || 4 || 4 ||4 || 12||
 * }


 * For each entry in the table, count all other entries that lie to the 'South East' of the particular entry. This is P:
 * P = (1 x 8) + (1 x 7) + (1 x 7) + (1 x 7) + (1 x 4) + (1 x 4) + (1 x 3) + ( 1 x 3) = 43


 * For each entry in the table, count all other entries that lie to the 'South West' of the particular entry. This is Q:
 * Q = (1 x 2) + (1 x 1) = 3


 * S = P - Q = 43 - 3
 * S = 40

Using Exact Tables
When the ties between samples are few (as in this example) Leach (1979)<Leach, C. (1979). “Introduction to statistics: A non-parametric approach for the social sciences”. Chichester: John Wiley. suggested that ignoring the ties and using exact tables would provide a reasonably accurate result. Jonckheere (1954) suggested breaking the ties against the alternative hypothesis and then using exact tables. In the current example where tied scores only appear in adjacent groups, the value of S is unchanged if the ties are broken again the alternative hypothesis. This may be verified by substituting 11 mph in place of 12 mph in the Bumped sample, and 19 mph in place of 20 mph in the Smashed and re-computing the test statistic. From tables with k = 3, and m = 4, the critical S value for α = .05 is 36 and thus the result would be declared statistically significant at this level.

Computing a Standard Normal Approximation
$$\text{As } n = 12\text{, }n^2=144 \text{ and } n^3 = 1728. \text{ Also}$$


 * $$t^2_i = 16$$


 * $$t^3_i = 24$$


 * $$u^2_i = 48$$


 * $$u^3_i = 192$$

The variance of S is then


 * $$\begin{align}\text{VAR}(S)=&\frac{2(1728 - 24 - 192)+3(144 - 16 - 48)+ 60}{18} \\

&+\frac{(24 - 48 + 24)(192 - 144 + 24)}{9 x 12 x 11 x 10} \\ &+\frac{(16 - 12)(48 - 12)}{2 x 12 x11} \\ &= 185.212\end{align}$$

And z is given by
 * $$z =\frac{S}{\sqrt{\text{VAR}(S)}}=\frac{40}{\sqrt{185.212}} = 2.939$$

For α = .05 (one-sided) the critical z value is 1.645, so again the result would be declared significant at this level. A similar test for trend within the context of repeated measures (within-participants) designs and based on Spearman's rank correlation coefficient was developed by Page (1963).