KTRND
Performs k‑sample trends test against ordered alternatives.
Required Arguments
NI — Vector of length NGROUP that contains the number of responses for each of the NGROUP groups. (Input)
X — Vector of length NI(1) + NI(2) + … + NI(NGROUP) containing the responses for each of the NGROUP groups. (Input)
All of the responses for group 1 come first, followed by group 2, and so on.
STAT — Vector of length 17 containing the test results. (Output)
I |
STAT(I) |
1 |
Test statistic (ties are randomized). |
2 |
Conservative test statistic with ties counted in favor of the null hypothesis. |
3 |
p‑value associated with STAT(1). |
4 |
p‑value associated with STAT(2). |
5 |
Continuity corrected STAT(3). |
6 |
Continuity corrected STAT(4). |
7 |
Expected mean of the statistic. |
8 |
Expected kurtosis of the statistic. (The expected skewness is zero. |
9 |
Total sample size. |
10 |
Coefficient of rank correlation based upon STAT(1). |
11 |
Coefficient of rank correlation based upon STAT(2). |
12 |
Total number of ties between samples. |
13 |
The t‑statistic associated with STAT(3). |
14 |
The t‑statistic associated with STAT(4). |
15 |
The t‑statistic associated with STAT(5). |
16 |
The t‑statistic associated with STAT(6). |
17 |
Degrees of freedom for each t‑statistic. |
Optional Arguments
NGROUP — Number of groups. (Input)
NGROUP must be greater than or equal to 3.
Default: NGROUP = size (NI,1).
FORTRAN 90 Interface
Generic: CALL KTRND (NI, X, STAT [, …])
Specific: The specific interface names are S_KTRND and D_KTRND.
FORTRAN 77 Interface
Single: CALL KTRND (NGROUP, NI, X, STAT)
Double: The double precision name is DKTRND.
Description
Routine KTRND 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 KTRND 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 (STAT(1)).
2. Ties are counted in a manner that is unfavorable to the alternative hypothesis (STAT (2)).
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 = NI(i). Let Skm denote the sum of all elements in Mkm. Then, STAT(2) 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 STAT(1), 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.
STAT(3) and STAT(4) are computed using the t distribution. The probabilities reported are asymptotic approximations based upon the t statistics in STAT(13) and STAT(14), which are computed as in Jonckheere (1954, page 141). Similarly, STAT(5) and STAT(6) give the probabilities for STAT(15) and STAT(16), the continuity corrected versions of STAT(3) and STAT(4). The degrees of freedom for each t statistic (STAT(17)) 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).
STAT(7), the variance of the test statistic STAT(1), and STAT(8), the kurtosis of the test statistic, are computed as in Jonckheere (1954, page 138). The coefficients of rank correlation in STAT(9) and STAT(10) 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)
H1 : F1(X) < F2(X) < … < Fk(X)
Reject if STAT(3) (or STAT(4), or STAT(5) or STAT(6), depending upon the method used) is too large.
Comments
1. Informational errors
Type |
Code |
Description |
3 |
4 |
At least one tie is detected in X. Randomization is used to break all ties. |
3 |
5 |
There are no degrees of freedom for the t‑statistics. STAT(3) to STAT(6) are set to 0. |
2. The closer STAT(10) and STAT(11) are to unity, the more one would be inclined to reject the hypothesis of randomness.
3. Routine RNUN (see Chapter 18, “Random Number Generation”) is used to randomly break ties. Routine RNSET (see Chapter 18) can be used to initialize the seed of the random number generator. The routine RNOPT (see Chapter 18) can be used to select the form of the generator.
Example
The following example is taken from Jonckheere (1954, page 135). It involves four observations in four independent samples.
USE RNSET_INT
USE KTRND_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER NGROUP
PARAMETER (NGROUP=4)
!
INTEGER NI(NGROUP), NOUT
REAL STAT(17), X(16)
!
DATA NI/4, 4, 4, 4/
DATA X/19, 20, 60, 130, 21, 61, 80, 129, 40, 99, 100, 149, 49, &
110, 151, 160/
!
CALL RNSET (123457)
! Get the statistics
CALL KTRND (NI, X, STAT)
! Print the results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) STAT
!
99999 FORMAT (' STAT(1) - Test statistic (random) ...........', F8.1, &
/, ' STAT(2) - Test statistic (null hypothesis) ..', &
F8.1, /, ' STAT(3) - p-value for STAT(1) ...............' &
, F12.5, /, ' STAT(4) - p-value for STAT(2) ', &
'...............', F12.5, /, ' STAT(5) - Continuity ', &
'corrected STAT(3) ......', F12.5, /, ' STAT(6) - ', &
'Continuity corrected STAT(4) ......', F12.5, /, &
' STAT(7) - Expected mean .....................', F8.1, &
/, ' STAT(8) - Expected kurtosis .................', &
F12.5, /, ' STAT(9) - Total sample size .................' &
, F8.1, /, ' STAT(10)- Rank corr. coef. based on STAT(1) ' &
, '.', F12.5, /, ' STAT(11)- Rank corr. coef. based on ', &
'STAT(2) .', F12.5, /, ' STAT(12)- Total number of ties ' &
, '..............', F8.1, /, ' STAT(13)- t-statistic ', &
'associated w/STAT(3) ..', F10.3, /, ' STAT(14)- ', &
't-statistic associated w/STAT(4) ..', F10.3, /, &
' STAT(15)- t-statistic associated w/STAT(5) ..', F10.3, &
/, ' STAT(16)- t-statistic associated w/STAT(6) ..', &
F10.3, /, ' STAT(17)- Degrees of freedom ................' &
, F10.3)
!
END
Output
STAT(1) - Test statistic (random) ........... 46.0
STAT(2) - Test statistic (null hypothesis) .. 46.0
STAT(3) - p-value for STAT(1) ............... 0.01483
STAT(4) - p-value for STAT(2) ............... 0.01483
STAT(5) - Continuity corrected STAT(3) ...... 0.01683
STAT(6) - Continuity corrected STAT(4) ...... 0.01683
STAT(7) - Expected mean ..................... 458.7
STAT(8) - Expected kurtosis ................. -0.15365
STAT(9) - Total sample size ................. 16.0
STAT(10)- Rank corr. coef. based on STAT(1) . 0.47917
STAT(11)- Rank corr. coef. based on STAT(2) . 0.47917
STAT(12)- Total number of ties .............. 0.0
STAT(13)- t-statistic associated w/STAT(3) .. 2.264
STAT(14)- t-statistic associated w/STAT(4) .. 2.264
STAT(15)- t-statistic associated w/STAT(5) .. 2.208
STAT(16)- t-statistic associated w/STAT(6) .. 2.208
STAT(17)- Degrees of freedom ................ 36.050