Journal of Statistical Computation and Simulation Vol. 76, No. 9, September 006, 89 837 A nonparametric test for trend based on initial ranks GLENN HOFMANN* and N. BALAKRISHNAN HSBC, USA ID Analytics, 15110 Avenue of Science, San Diego, CA 918, USA Received 8 December 004; in final form 8 May 005) We compare the power of several nonparametric statistics for testing the hypothesis of an i.i.d. sequence against the alternative of an increasing trend in location or scale. We introduce a new test based on initial ranks and display it to perform consistently as good as or better than the classical tests due to Kendall and Spearman. The same is true for a test based on inverse-normally transformed ranks. Keywords: Hypothesis of randomness; Trend; Location trend; Nonparametric tests; Scale trend; Ranks; Initial ranks; Power simulation 1. Introduction In many practical situations, it is important to test for the randomness of a series of observations, i.e. the hypothesis that X 1,...,X n are independent and identically distributed i.i.d.) There is a large class of relevant alternatives and no single test is likely to be efficient against all of them. We will focus on the alternative of an increasing trend in the series. Let U 1,...,U n be i.i.d. with unknown distribution function F and let X i = U i + βti), i = 1,...,n, β R, 1) where ti) is a strictly increasing function. Then, β = 0 corresponds to the null hypothesis of randomness, and β>0 marks an increasing trend in location. The trend function ti) can have different shapes. Linear, logarithmic and polynomial trends are the most commonly considered. For positive random variables with means related to scale changes, we may also be interested in scale trends, corresponding to β>0 in the model X i = U i 1 + βti)), i = 1,...,n, β R, ) and once again ti) is strictly increasing. Several nonparametric test statistics have been proposed for such trend alternatives. Let R i i = 1,...,n) be the rank of X i in X 1,...,X n *Corresponding author. Email: glennhofmann@yahoo.com Journal of Statistical Computation and Simulation ISSN 0094-9655 print/issn 1563-5163 online 006 Taylor & Francis http://www.tandf.co.uk/journals DOI: 10.1080/106936060056494
830 G. Hofmann and N. Balakrishnan when ordered from smallest to largest. Mann [1] considered Kendall s statistic Q = signr j R i ), where 1 i<j n 1 if x>0 signx) = 1 if x<0, 3) 0 ifx = 0 which is related to Kendall s rank correlation coefficient τ by τ = Q/nn 1). To this date, Q remains the omnipotent nonparametric trend test of choice. It has high power for a variety of underlying distributions. Daniels [] compared Q with Spearman s rank correlation coefficient 1 r S = i n + 1 ) R nn i n + 1 ) ) 1 nn + 1) = ir 1) nn i. 1) 4 4) He pointed out that Q and r S do not measure the same aspect of dependence and showed that r S is optimal for testing against linear trends ti) = i in 1)) in the class of linear combinations of { 1 R j >R i I {Rj >R i } = 0 otherwise. Stuart [3, 4] compared the asymptotic relative efficiencies of several trend tests in case of an underlying normal distribution. He found Q and r S to be the most powerful nonparametric options. Aiyar et al. [5] gave a more extensive asymptotic comparison of rank tests for trend alternatives. They introduced several other rank statistics which are asymptotically optimal for certain distributions and trends. Most notably, they presented M = i n + 1 ) ) 1 Ri n + 1 and B = i n + 1 ) sign R i n + 1 ), 6) which are the asymptotically optimal linear rank statistics for a linear trend with an underlying normal and double-exponential distributions, respectively. Here, denotes the standard normal distribution function. Foster and Stuart [6] introduced a nonparametric trend test based on records. Let Nn UN n L) be the number of upper lower) records in the sequence X 1,...,X n, where X i is an upper lower) record if and only if X i > <)X j for all 1 j<i. Similarly, let Nn U,N L n be the numbers of upper and lower records, respectively, in the reverse sequence X n,...,x 1. Foster and Stuart [6] defined their test statistic as D = Nn U N n L U ) Nn 5) Nn L ). 7) See Arnold et al. [7, chapter 5) for further details. According to Stuart [3], for location trends in normal distributions, its asymptotic efficiency vanishes when compared with Kendall s Q.
A nonparametric test for trend based on initial ranks 831 On the other hand, Diersen and Trenkler [8] showed that for polynomial location trends in uniform and exponential distributions, the asymptotic efficiency of D is infinitely greater than that of Q. However, this asymptotic statement is not readily reflected in small or moderate sample sizes. Our own simulations reveal for n 100 exponential) and n 50 uniform), Q in fact to be more powerful than D. Although these asymptotic comparisons have been made in the literature for test statistics mentioned earlier, we are not aware of any work considering finite sample sizes. In this article, we propose a different nonparametric trend test and compare its small-sample performance to the procedures mentioned earlier. In section, we will introduce initial ranks and derive a new class of test statistics on the basis of this concept. We will see that this approach allows us to look at the previously mentioned statistics from a different point of view, which will enable us to combine their advantages. In section 3, we use Monte Carlo simulations to perform a power comparison for various distributions, trends and sample sizes. On the basis of this extensive simulation study, it turns out that M as well as our new statistic G are consistently more powerful or at least as good as the Kendall s Q and Spearman s r S statistics. In section 4, we apply several trend test statistics to monthly ozone data from Los Angeles and observe their performance.. A class of test statistics based on initial ranks In a sequence of observations X 1,...,X n, let ρ k ={number of X i X k, 1 i k}, 1 k n, 8) denote the initial rank of X k, i.e. the rank of X k when it first appears. Further, let ρ n+1 k ={number of X i X k,k i n} 9) be the initial rank of X k in the reverse sequence X n,...,x 1, where it is the n + 1 k)th observation. Note that the two types of initial ranks determine the rank through the identity R k = ρ k + ρn+1 k 1, k = 1,...,n. 10) There is a one-to-one relation between the sequence {R k } of ranks and the sequence {ρ k } of initial ranks. As large initial ranks are directly related to increasing trends, they provide an intuitive tool for the derivation of test statistics. Let us first express Kendall s Q, Spearman s r S and Foster and Stuart s D in terms of the ρ k s. Note that equation 3) can be written as Q = i<j I {Xi <X j } i<j I {Xi >X j }, where I { } equals 1 if { } holds and zero otherwise. Resolving the first sum over i and the second sum over j, we readily have Q = = n 1 ρ j 1) ρn+1 i 1) j= ρ k ρk. 11)
83 G. Hofmann and N. Balakrishnan Next, in order to express r S using initial ranks, observe that equation 10) implies nn + 3) = R k + 1) = ρ k + Using equations 10) and 1), we can express r S in equation 4) in the form r S = 1 nn 1) { k n + 1 ) ρ k ρk. 1) k n + 1 ) } ρk. 13) Finally, as lower records are characterized by having initial rank one, and upper records by having maximal initial rank, equation 7) can be written as D = a k ρ k ) a k ρk ), where 1 ifρ = k a k ρ) = 1 if ρ = 1. 14) 0 otherwise From equations 11), 13) and 14), we readily observe that Q, r S and D all have the form b k ρ k ) b k ρk ), where b k is some function which is nondecreasing for Q and D. This makes intuitive sense because both large ρ k and small ρ k indicate an increasing trend. The expression b kρ k ) implicitly includes two components. First, it weighs the observation number linearly in Q, because ρ k {1,...,k} can be larger for larger k, and quadratically in r S because of an additional linear factor. Secondly, it depends on a nondecreasing function of the initial rank within the observation number, i.e. its actual values on {1,...,k}. This will become clear in a moment, as we separate the two components in order to modify them independently. We standardize the initial ranks to be in the interval [ 1, 1] γ 1 = γ1 = 0, γ k = ρ k k + 1)/), γk k 1/) = ρ k and consider test statistics of the class wk 1)gγ k ) k + 1)/), k =,...,n, 15) k 1/) wk 1)gγk ), 16) where w is the weight function of the observation number and g the influence function of the initial rank. As later observations have more information about trends, and higher initial ranks indicate upward behaviour, both w and g should typically be increasing functions.
A nonparametric test for trend based on initial ranks 833 Straightforward calculations show that Q, r S and D are in the class 16) with the following components: Q: w Q x) = 1 x, g Qx) = x, [ 6 r S : w r x) = x n 1 ] x, g nn r x) = x, 17) 1) 1 if x = 1 D: w D x) = 1, g D x) = 1 if x = 1. 0 otherwise To combine the advantages of these statistics, we can use an influence function g that accommodates the linear case Q, r S ), the weighing of extremes D) and any intermediate situation, by means of a parameter. Possible choices are or g 1 x; a) = arctanhax) arctanha) log1 + ax)/1 ax)) =, a 0, 1) log1 + a)/1 a)) g x; a) = 1 ax + 1)/), a 0, 1). 1 a + 1)/) As both give very similar results, we prefer g 1 for its ease of computation. For small a,g 1 is close to linear, whereas for a 1, g 1 x; a) g D x). We tried several weight functions, obtaining the best overall power with cubic weights wx) = x 3. On the basis of these observations, we propose the test statistic Ga) = )) 1 + a 1 log k 1) log 3 1 a 1 + aγk 1 aγ k ) 1 + aγ )) log k 1 aγk. 18) The parameter a 0, 1) will be chosen according to n, where a larger a typically works better for a larger n. The subsequent Monte Carlo simulations and the example of section 4 illustrate some choices of a. Table 4 gives recommended parameter values. For the simulations in the following section, we use a = 0.8 for n = 10 and a = 0.995 for n = 100. 3. Monte Carlo power comparison We performed Monte Carlo power simulations for n = 10 and n = 100 using the test statistics given previously. An initial simulation under the null hypothesis determined the critical values at the α = 0.05 level of significance. We then simulated the power under the alternative hypotheses 1) and ) with linear, logarithmic and quadratic trend functions. For the location hypothesis 1), we used the following underlying models for the U i s: standard normal, standard exponential, standard uniform, standard Laplace, standard logistic and skew-normal with density fx; λ = 5) = λx)φx) [9, 10], where and φ are the standard normal c.d.f. and density, respectively. The scale alternative ) is only appropriate for trend tests if the variables are positive. We considered it for the standard exponential and uniform distributions when n = 100. For n = 10, even for large trends β, none of the tests were able to detect the scale alternative with reasonable power. The only exception is the quadratic trend in a uniform model. The results are summarized in tables 1 and. For a good standard comparison, we chose the trend coefficient β, such that Kendall s Q achieves power between 0.5 and 0.6. The true
834 G. Hofmann and N. Balakrishnan Table 1. Power comparison for n = 100. Power Q r S D B M G0.995) Model standard form) Trend Type β 0.050 0.050 0.044 0.050 0.050 0.050 Normal Linear Location 0.006 0.5 0.5 0.13 0.39 0.53 0.5 Normal Log Location 0.3 0.58 0.58 0. 0.44 0.59 0.6 Normal Quadratic Location 0.00006 0.5 0.53 0.13 0.4 0.54 0.53 Exponential Linear Location 0.004 0.57 0.56 0.47 0.3 0.65 0.73 Exponential Log Location 0.13 0.5 0.51 0.55 0.7 0.61 0.75 Exponential Quadratic Location 0.000037 0.53 0.5 0.39 0.3 0.59 0.64 Uniform Linear Location 0.0018 0.54 0.54 0.6 0.8 0.68 0.78 Uniform Log Location 0.07 0.6 0.6 0.75 0.3 0.74 0.84 Uniform Quadratic Location 0.000018 0.54 0.54 0.6 0.8 0.68 0.78 Exponential Linear Scale 0.01 0.5 0.5 0.14 0.38 0.53 0.53 Exponential Log Scale 0.8 0.5 0.5 0.1 0.39 0.5 0.5 Exponential Quadratic Scale 0.00009 0.5 0.53 0.14 0.38 0.54 0.54 Uniform Linear Scale 0.0045 0.5 0.51 0.43 0.9 0.6 0.68 Uniform Log Scale 0.5 0.56 0.55 0.51 0.36 0.6 0.65 Uniform Quadratic Scale 0.000045 0.55 0.54 0.45 0.3 0.64 0.74 Skewed normal λ = 5) Linear Location 0.0035 0.53 0.54 0.17 0.36 0.57 0.58 Skewed normal λ = 5) Log Location 0.1 0.51 0.5 0.4 0.34 0.56 0.6 Skewed normal λ = 5) Quadratic Location 0.000035 0.54 0.54 0.17 0.37 0.56 0.56 Double exponential Linear Location 0.007 0.54 0.54 0.08 0.55 0.49 0.44 Double exponential Log Location 0.5 0.54 0.54 0.11 0.53 0.49 0.46 Double exponential Quadratic Location 0.00007 0.53 0.54 0.08 0.55 0.49 0.44 Logistic Linear Location 0.01 0.51 0.5 0.1 0.4 0.5 0.47 Logistic Log Location 0.36 0.5 0.5 0.14 0.4 0.51 0.49 Logistic Quadratic Location 0.0001 0.5 0.5 0.1 0.4 0.5 0.48 Table. Power comparison for n = 10. Power Q r S D B M G0.8) Model standard form) Trend Type β 0.036 0.048 0.043 0.047 0.050 0.050 Normal Linear Location 0.5 0.545 0.619 0.418 0.467 0.63 0.64 Normal Log Location 1. 0.586 0.649 0.50 0.47 0.666 0.674 Normal Quadratic Location 0.03 0.539 0.61 0.415 0.455 0.66 0.6 Exponential Linear Location 0.18 0.59 0.568 0.44 0.456 0.576 0.587 Exponential Log Location 0.8 0.519 0.553 0.489 0.416 0.565 0.59 Exponential Quadratic Location 0.017 0.533 0.574 0.4 0.46 0.581 0.587 Uniform Linear Location 0.075 0.53 0.605 0.469 0.411 0.631 0.65 Uniform Log Location 0.35 0.556 0.64 0.533 0.409 0.653 0.66 Uniform Quadratic Location 0.007 0.537 0.61 0.471 0.41 0.638 0.63 Uniform Quadratic Scale 0.04 0.534 0.574 0.49 0.466 0.58 0.59 Skewed normal λ = 5) Linear Location 0.14 0.508 0.574 0.404 0.434 0.587 0.584 Skewed normal λ = 5) Log Location 0.7 0.574 0.63 0.514 0.455 0.647 0.66 Skewed normal λ = 5) Quadratic Location 0.013 0.507 0.574 0.393 0.435 0.586 0.581 Double exponential Linear Location 0.3 0.536 0.591 0.381 0.489 0.593 0.59 Double exponential Log Location 1.4 0.551 0.599 0.441 0.475 0.606 0.618 Double exponential Quadratic Location 0.08 0.537 0.59 0.386 0.483 0.595 0.595 Logistic Linear Location 0.4 0.59 0.598 0.381 0.468 0.605 0.599 Logistic Log Location 0.561 0.6 0.467 0.464 0.633 0.64 Logistic Quadratic Location 0.04 0.547 0.615 0.408 0.474 0.64 0.619
A nonparametric test for trend based on initial ranks 835 α s are given underneath the symbol of each test statistic. To assure the given accuracy of the simulated power, we used 1,000,000 simulations for n = 10 and 58,000 for n = 100. We performed the runs in S-Plus on a Pentium IV machine, where each run took between 9 n = 100) and 43 n = 10) min. From tables 1 and, we observe that G and M have consistently higher or equal power when compared with the Q and r S statistics. G and M have similar performances, with G having higher power for n = 100 in the exponential and uniform location cases. In addition, G and M have the advantage of being more continuous than the Q and r S statistics and consequently, one can achieve a desired α-level more closely. 4. Example Let us consider the data set of monthly averages of hourly ozone readings in downtown Los Angeles from 1955 to 197 figure 1), as given by Box et al. [11]. It shows a decreasing trend that is somewhat obscured by seasonal effects. All test statistics clearly identify the trend p-values < 0.001), when the complete data set is used. Hence, using the complete data set makes it difficult to compare among them. We can, however, look at shorter intervals of consecutive observations where the trend will be harder to detect, and a more apparent test statistic comparison can be made. We used consecutive k-year intervals k = 4,...,10) from the 18 years of data, each starting in January. Hence, there are 19 k such intervals starting in years 1955, 1956,...,1973 k. For each test statistic, we obtained the median p-values over all intervals with the same k) because this robust measure can give us a clear idea of how each test statistic behaves on shorter stretches of the sample data. Results are given in table 3. We estimated the null distributions for all test statistics null hypothesis of β = 0 in equations 1) and ), implying i.i.d. observations) from 5,000 Monte Carlo simulations. The G0.99), G0.995) and G0.999) statistics show Figure 1. Monthly averages of hourly ozone readings in downtown Los Angeles from 1955 to 197, as given by Box et al. [11].
836 G. Hofmann and N. Balakrishnan Table 3. Decreasing trend alternative in monthly ozone data figure 1): median p-values for the 19 k) possibilities of consecutive k-year intervals. Number Subset Number of of k-year length in ozone readings intervals years k) n = 1k) 19 k) Q r S D B M G0.99) G0.995) G0.999) 4 48 15 0.77 0.56 0.69 0.15 0.361 0.18 0.173 0.17 5 60 14 0.11 0.095 0.198 0.07 0.167 0.08 0.079 0.075 6 7 13 0.037 0.033 0.79 0.019 0.09 0.03 0.0 0.018 7 84 1 0.069 0.06 0.10 0.04 0.051 0.01 0.016 0.008 8 96 11 0.086 0.071 0.04 0.05 0.064 0.044 0.036 0.03 9 108 10 0.094 0.091 0.037 0.055 0.089 0.08 0.03 0.014 10 10 9 0.017 0.017 0.03 0.011 0.049 0.008 0.007 0.006 Table 4. Percentiles of Ga) that can be used as critical values in tests. Percentiles of Ga) Recommended n values of a 90% 95% 97.5% 99% 99.5% 10 0.8 1400 1760 060 390 600 0 0.9 15,000 19,000,500 6,500 9,000 30 0.95 56,800 7,700 85,800 101,000 111,000 40 0.99 18,000 165,000 195,000 31,000 57,000 50 0.99 77,000 35,000 419,000 497,000 545,000 60 0.99 513,000 656,000 78,000 96,000 1,00,000 70 0.99 865,000 1,10,000 1,340,000 1,570,000 1,730,000 80 0.99 1,80,000 1,640,000 1,960,000,300,000,550,000 90 0.995 1,910,000,450,000,930,000 3,470,000 3,830,000 100 0.995,760,000 3,530,000 4,00,000 4,980,000 5,50,000 15 0.999 5,00,000 6,410,000 7,640,000 9,110,000 10,000,000 150 0.999 9,350,000 1,000,000 14,300,000 16,900,000 18,700,000 Note: Ga) has a symmetric distribution around 0. consistently lower p-values than all other test statistics and hence appear to be better able to detect the trend. Recommendations for the parameter a are given in the following section, in conjunction with table 4. 5. Conclusions We introduced a new test statistic Ga) for location and scale trend alternatives to the null hypothesis of a random series of observations Ga) = )) 1 + a 1 log k 1) log 3 1 a 1 + aγk 1 aγ k ) 1 + aγ )) log k 1 aγk, 19) where γ 1 = γ 1 = 0, γ k = ρ k k + 1)/)/k 1)/), γ k = ρ k k + 1)//k 1)/) k =,...,n)and ρ, ρ are the initial ranks defined in equations 8) and 9), respectively. For a variety of trends and distributions, Ga) is at least as or more powerful as the classical tests of Kendall and Spearman or other tests considered here. Therefore, Ga) can be used as an omnipotent statistic for detecting trends. Recommended values of a and selected percentiles
A nonparametric test for trend based on initial ranks 837 of Ga) are given in table 4 for some values of n. Forn>150,a = 0.999 can be used. The table was obtained from 100,000 simulations of the null distributions, which allow reasonable accuracy to the three given significant digits. References [1] Mann, H.B., 1945, Nonparametric test against trend. Econometrica, 13, 45 59. [] Daniels, H.E., 1950, Rank correlation and population models. Journal of Royal Statistical Society Series B, 1, 171 181. [3] Stuart, A., 1954, Asymptotic relative efficiencies of distribution-free tests of randomness against normal alternatives. Journal of American Statistical Association, 49, 147 157. [4] Stuart, A., 1956, The efficiencies of tests of randomness against normal regression. Journal of American Statistical Association, 51, 85 87. [5] Aiyar, R.J., Guillier, C.L. andalbers, W., 1979,Asymptotic relative efficiencies of rank tests for trend alternatives. Journal of American Statistical Association, 74, 6 31. [6] Foster, F.G. and Stuart, A., 1954, Distribution-free tests in time series based on the breaking of records. Journal of Royal Statistical Society Series B, 16, 1. [7] Arnold, B.C., Balakrishnan, N. and Nagaraja, H.N., 1998, Records New York: John Wiley). [8] Diersen, J. and Trenkler, G., 1996, Records tests for trend in location. Statistics, 8, 1 1. [9] Azzalini, A., 1985, A class of distributions which includes the normal ones. Scandinavian Journal of Statistics, 1, 171 178. [10] Johnson, N.L., Kotz, S. and Balakrishnan, N., 1994, Continuous Univariate Distributions nd edn), Vol. 1 New York: John Wiley). [11] Box, G.E.P., Jenkins, G.M. and Reinsel, G.C., 1994, Time Series Analysis Forecasting and Control New Jersey: Prentice Hall).