NCTRD
Performs the Noether test for cyclical trend.
Required Arguments
X — Vector of length NOBS containing the observations in chronological order. (Input)
FUZZ — Value to be used in determining when consecutive observations in X are tied. (Input)
If ∣X(i + 1) ‑ X(i)∣ is less than or equal to FUZZ, then X(i + 1) and X(i) are said to be tied.
NSTAT — Vector of length 6 containing output statistics. (Output)
I |
NSTAT(I) |
1 |
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. |
2 |
The number of monotonic sequences of length three in the set defined by NSTAT(1). |
3 |
The number of monotonic sequences where tied threesomes are counted as nonmonotonic. |
4 |
The number of monotonic sequences where tied threesomes are counted as monotonic. |
5 |
The number of middle observations eliminated because they were tied in forming the NSTAT(1) sequences. |
6 |
The number of tied sequences found in forming the NSTAT(3) and NSTAT(4) sequences. A sequence is called a tied sequence if the middle element is tied with either of the two other elements. |
P — Vector of length 3 containing the probabilities of NSTAT(2) or more, NSTAT(3) or more, or NSTAT(4) or more monotonic sequences. (Output)
If NSTAT(1) is less than 1, P(1) is set to NaN (not a number).
Optional Arguments
NOBS — Number of observations. (Input)
NOBS must be greater than or equal to 3.
Default: NOBS = size (X,1).
NMISS — Number of missing (NaN, not a number) values in X. (Output)
FORTRAN 90 Interface
Generic: CALL NCTRD (X, FUZZ, NSTAT, P [, …])
Specific: The specific interface names are S_NCTRD and D_NCTRD.
FORTRAN 77 Interface
Single: CALL NCTRD (NOBS, X, FUZZ, NSTAT, P, NMISS)
Double: The double precision name is DNCTRD.
Description
Routine NCTRD 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(2), NSTAT(3), and NSTAT(4), 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(2), tied middle observations are eliminated, and a new set of size 3 is obtained by using the next observation in the sample. In NSTAT(3), the original set of size three is used, and tied middle observations are counted as nonmonotonic. In NSTAT(4), 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 P(1) (or P(2) or P(3) 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.
Comments
1. Informational errors
Type |
Code |
Description |
3 |
3 |
NSTAT(1), which is used to determine NSTAT(3) and NSTAT(4), is less than 8. The asymptotic probabilities will not be exact. |
3 |
4 |
At least one tie was detected in X. |
2. If NOBS is greater than or equal to 3 but NSTAT(1) is less than one, P(1) will be set to NaN. The remaining statistics and associated probabilities will be determined and returned as described.
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.
! SPECIFICATIONS FOR PARAMETERS
USE IMSL_LIBRARIES
IMPLICIT NONE
INTEGER NOBS
REAL FUZZ
PARAMETER (FUZZ=0.0, NOBS=1000)
!
INTEGER ISEED, NSTAT(6)
REAL P(3), X(NOBS)
!
DATA ISEED/123457/
!
CALL RNSET (ISEED)
CALL RNUN (X)
! Noether test
CALL NCTRD (X, FUZZ, NSTAT, P)
! Print results
CALL WRIRN (’NSTAT’, NSTAT, 1, 6, 1, 0)
CALL WRRRN (’P’, P, 1, 3, 1, 0)
!
END
Output
NSTAT
1 2 3 4 5 6
333 107 107 107 0 0
P
1 2 3
0.6979 0.6979 0.6979