NCTRENDS Function
Performs the Noether test for cyclical trend.
Usage
result = NCTRENDS(x)
Input Parameters
x—One-dimensional array containing the data in chronological order.
Returned Value
result—One-dimensional array of length 3 containing the probabilities of Nstat(1) or more, Nstat(2) or more, or Nstat(3) or more monotonic sequences. If Nstat(0) is less than 1, result(0) is set to NaN (not a number).
Input Keywords
Double—If present and nonzero, double precision is used.
Fuzz—Nonnegative constant used to determine ties in computing ranks in the combined samples. A tie is declared when two observations in the combined sample are within Fuzz of each other. Default: Fuzz = 0.0.
Output Keywords
Nstat—Named variable into which the one-dimensional array of length 6 containing the statistics below is stored:
Nstat (0)—The number of consecutive sequences of length three used to detect cyclical trend when tying middle elements are eliminated from the sequence, and the next consecutive observation is used.
Nstat (1)—The number of monotonic sequences of length three in the set defined by
Nstat(0).
Nstat (2)—The number of nonmonotonic sequences where tied threesomes are counted as nonmonotonic.
Nstat (3)—he number of monotonic sequences where tied threesomes are counted as monotonic.
Nstat (4)—The number of middle observations eliminated because they were tied in forming the
Nstat(0) sequences.
Nstat (5)—The number of tied sequences found in forming the
Nstat(2) and
Nstat(3) sequences. A sequence is called a tied sequence if the middle element is tied with either of the two other elements.
Nmissing—Named variable into which the number of missing values in x is stored.
Discussion
Routine NCTRENDS performs the Noether test for cyclical trend (Noether 1956) for a sequence of measurements. In this test, the observations are first divided into sets of three consecutive observations. Each set is then inspected, and if the set is monotonically increasing or decreasing, the count variable is incremented.
The count variables, Nstat(1), Nstat(2), and Nstat(3), differ in the manner in which ties are handled. A tie can occur in a set (of size three) only if the middle element is tied with either of the two ending elements. Tied ending elements are not considered. In Nstat(1), tied middle observations are eliminated, and a new set of size 3 is obtained by using the next observation in the sample. In Nstat(2), the original set of size three is used, and tied middle observations are counted as nonmonotonic. In Nstat(3), tied middle observations are counted as monotonic.
The probabilities of occurrence of the counts are obtained from the binomial distribution with p = 1/3, where p is the probability that a random sample of size three from a continuous distribution is monotonic. The binomial sample size is, of course, the number of sequences of size three found (adjusted for ties).
Hypothesis test:
H0 : q = Pr(Xi > Xi - 1 > Xi - 2) + Pr(Xi < Xi - 1 < Xi - 2 ) ≤ 1/3 H1: q > 1/3
Reject if result(0) (or result(1) or result(2) depending on the method used for handling ties) is less than the significance level of the test.
Assumption: The observations are independent and are from a continuous distribution.
Example
A test for cyclical trend in a sequence of 1000 randomly generated observations is performed. Because of the sample used, there are no ties and all three test statistics yield the same result.
RANDOMOPT, set = 123457
x = RANDOM(1000, /Uniform)
pval = NCTRENDS(x, Nstat = nstat)
PM, pval
; PV-WAVE prints the following:
; 0.697881
; 0.697881
; 0.697881
PM, nstat
; PV-WAVE prints the following:
; 333
; 107
; 107
; 107
; 0
; 0