The IMSL_KTRENDS function performs a k-sample trends test against ordered alternatives.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_KTRENDS function performs a k-sample trends test against ordered alternatives. The alternative to the null hypothesis of equality is that F1(X) < F2(X) < ... Fk(X), where F1, F2, etc., are cumulative distribution functions, and the operator < implies that the less than relationship holds for all values of x. While the trends test used in IMSL_KTRENDS requires that the background populations be continuous, ties occurring within a sample have no effect on the test statistic or associated probabilities. Ties between samples are important, however. Two methods for handling ties between samples are used. These are:

  1. Ties are randomly split (Result(0)).
  2. Ties are counted in a manner that is unfavorable to the alternative hypothesis (Result(1)).

Computational Procedure


Consider the matrices:

where Xki is the i-th observation in the k-th population, Xmj is the j-th observation in the m-th population, and each matrix Mkm is nk by nm where ni = n(i). Let Skm denote the sum of all elements in Mkm. Then, Result(1) is computed as the sum over all elements in Skm, minus the expected value of this sum (computed as:

when there are no ties and the distributions in all populations are equal). In Result(0), ties are broken randomly, and the element in the summation is taken as 2.0 or 0.0 depending upon the result of breaking the tie.

Result(2) and Result(3) are computed using the t distribution. The probabilities reported are asymptotic approximations based upon the t statistics in Result(12) and Result(13), which are computed as in Jonckheere (1954, page 141).

Similarly, Result(4) and Result(5) give the probabilities for Result(14) and Result(15), the continuity corrected versions of Result(2) and Result(3). The degrees of freedom for each t statistic (Result(16)) are computed so as to make the t distribution selected as close as possible to the actual distribution of the statistic (see Jonckheere 1954, page 141).

Result(6), the variance of the test statistic Result(0), and Result(7), the kurtosis of the test statistic, are computed as in Jonckheere (1954, page 138). The coefficients of rank correlation in Result(8) and Result(9) reduce to the Kendall t statistic when there are just two groups.

Exact probabilities in small samples can be obtained from tables in Jonckheere (1954). Note, however, that the t approximation appears to be a good one.

Assumptions


  1. The Xmi for each sample are independently and identically distributed according to a single continuous distribution.
  2. The samples are independent.

Hypothesis Tests


H0 : F1(X) ≥ F2(X) ≥ ... ≥ Fk(X)
H
1 : F1(X) < F2(X) < ... < Fk(X)
Reject if Result(2) (or Result(3), or Result(4) or Result(5), depending upon the method used) is too large.

Example


The following example is taken from Jonckheere (1954, page 135). It involves four observations in four independent samples.

y	=	[19.0, 20.0, 60.0, 130.0, 21.0, 61.0, 80.0, 129.0, $
40.0, 99.0, 100.0, 149.0, 49.0, 110.0, 151.0, 160.0]
n  = [4, 4,  4,  4]
rlabel = ['stat(0) - Test Statistic (random) .............', $
  'stat(1) - Test Statistic (null hypothesis) ....', $
  'stat(2) - p-value for stat(0) .................', $
  'stat(3) - p-value for stat(1) .................', $
  'stat(4) - Continuity corrected for stat(2) ....', $
  'stat(5) - Continuity corrected for stat(3) ....', $
  'stat(6) - Expected mean .......................', $
  'stat(7) - Expected kurtosis ...................', $
  'stat(8) - Total sample size ...................', $
  'stat(9) - Rank corr. coef. based on stat(0) ...', $
  'stat(10)- Rank corr. coef. based on stat(1) ...', $
  'stat(11)- Total number of ties ................', $
  'stat(12)- t-statistic associated w/stat(2) ....', $
  'stat(13)- t-statistic associated w/stat(3) ....', $
  'stat(14)- t-statistic associated w/stat(4) ....', $
  'stat(15)- t-statistic associated w/stat(5) ....', $
  'stat(16)- Degrees of freedom ..................']
s  = IMSL_KTRENDS(n, y)
FOR i = 0, 16 DO PM, rlabel(i), s(i), FORMAT = '(A45, F10.5)'
 
stat(0) - Test Statistic (random) ............  46.00000
stat(1) - Test Statistic (null hypothesis) ...  46.00000
stat(2) - p-value for stat(0) .................  0.01483
stat(3) - p-value for stat(1) .................  0.01483
stat(4) - Continuity corrected for stat(2) ....   0.01683
stat(5) - Continuity corrected for stat(3) ..,.   0.01683
stat(6) - Expected mean ..................... 458.66666
stat(7) - Expected kurtosis ..................  -0.15365
stat(8) - Total sample size ..................  16.00000
stat(9) - Rank corr. coef. based on stat(0) ...  0.47917
stat(10)- Rank corr. coef. based on stat(1) ...  0.47917
stat(11)- Total number of ties ................  0.00000
stat(12)- t-statistic associated w/stat(2) ....  2.26435
stat(13)- t-statistic associated w/stat(3) ....  2.26435
stat(14)- t-statistic associated w/stat(4) ....  2.20838
stat(15)- t-statistic associated w/stat(5) ....  2.20838
stat(16)- Degrees of freedom .................  36.04963

Syntax


Result = IMSL_KTRENDS(N, Y [, /DOUBLE])

Return Value


One-dimensional array of length 17 containing the test results.

  • 0: Test statistic (ties are randomized).
  • 1: Conservative test statistic with ties counted in favor of the null hypothesis.
  • 2: p-value associated with Result(0).
  • 3: p-value associated with Result(1).
  • 4: Continuity corrected Result(2).
  • 5: Continuity corrected Result(3).
  • 6: Expected mean of the statistic.
  • 7: Expected kurtosis of the statistic. (The expected skewness is zero.)
  • 8: Total sample size.
  • 9: Coefficient of rank correlation based upon Result(0).
  • 10: Coefficient of rank correlation based upon Result(1).
  • 11: Total number of ties between samples.
  • 12: The t-statistic associated with Result(2).
  • 13: The t-statistic associated with Result(3).
  • 14: The t-statistic associated with Result(4).
  • 15: The t-statistic associated with Result(5).
  • 16: Degrees of freedom for each t-statistic.

Arguments


N

One-dimensional array containing the number of responses for each of the groups.

Y

One-dimensional array that contains the responses for each of the groups. Y must be sorted by group, with the n(0) observations in group 1 coming first, the n(1) observations in group two coming second, and so on.

Keywords


DOUBLE (optional)

If present and nonzero, then double precision is used.

Version History


6.4

Introduced