IMSL Statistics Reference Guide > Nonparametric Statistics > KTRENDS Function (PV-WAVE Advantage)
  

KTRENDS Function (PV-WAVE Advantage)
Performs a k-sample trends test against ordered alternatives.
Usage
result = KTRENDS(n, y)
Input Parameters
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.
Returned Value
result—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.
Input Keywords
Double—If present and nonzero, double precision is used.
Discussion
Function KTRENDS 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 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 ith observation in the kth population, Xmj is the jth observation in the mth 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 τ 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  =  KTRENDS(n, y)
FOR i=0L, 16 DO PM, rlabel(i), s(i), Format = '(A45, F10.5)'
 
; This results in the following output:
 
; 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

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.