== Jonckheere's Trend Test == (Hacked from [[http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=468904#B4|here.]]) The Jonckheere–Terpstra test There are situations in which treatments are ordered in some way, for example the increasing dosages of a drug. In these cases a test with the more specific alternative hypothesis that the population medians are ordered in a particular direction may be required. For example, the alternative hypothesis could be as follows: population median1 ≤ population median2 ≤ population median3. This is a one-tail test, and reversing the inequalities gives an analagous test in the opposite tail. Here, the Jonckheere–Terpstra test can be used for k groups, with test statistic TJT calculated as: $$\sum U(xy)$$ - 1/4 ( $$N^2 ^$$ - $$\sum$$ [j=1 to k] n(j)^2 ^) divided by the square root of (1/72)(N^2 ^ (2N+3)- $$\sum$$ [j=1 to k] n(j)^2 ^ (2n(j)+3)) Where U(xy) is the number of observations in group y that are greater than each observation in group x and n(j) is the size of group j. This is compared with a standard Normal distribution. This test will be illustrated using the data in Table 1 with the alternative hypothesis that time spent by patients in the three ICUs increases in the order cardiothoracic (ICU 1), medical (ICU 2) and neurosurgical (ICU 3). U(12) compares the observations in ICU 1 with ICU 2. It is calculated as follows. The first value in sample 1 is 7; in sample 2 there are three higher values and a tied value, giving 7 the score of 3.5. The second value in sample 1 is 1; in sample 2 there are 5 higher values giving 1 the score of 5. U(12) is given by the total scores for each value in sample 1: 3.5 + 5 + 5 + 4 + 2.5 + 3 = 23. In the same way U(13) is calculated as 6 + 6 + 6 + 6 + 4.5 + 6 = 34.5 and U(23) as 6 + 6 + 2 + 4.5 + 1 = 19.5. Comparisons are made between all combinations of ordered pairs of groups. For the data in Table 1 the test statistic is calculated as follows: '''formula to be inserted''' Comparing this with a standard Normal distribution gives a P value of 0.005, indicating that the increase in length of stay with ICU is significant, in the order cardiothoracic, medical and neurosurgical. [[FAQ/pagesL|Page's L test]] is a nonparametric trend test for ''repeated measures'' data where, for example, we wish to see if cognitive tests form a trend where each person has a score on each test. It is available for use in R but is not in SPSS.