CNL Stat : Nonparametric Statistics : noether_cyclical_trend
noether_cyclical_trend
Performs the Noether test for cyclical trend.
Synopsis
#include <imsls.h>
float *imsls_f_noether_cyclical_trend (int n_observations, float x[], ..., 0)
The type double function is imsls_d_noether_cyclical_trend.
Required Arguments
int n_observations (Input)
Number of observations in x. n_observations must be greater than or equal to 3.
float x[] (Input)
Array of length n_observations containing the data in chronological order.
Return Value
Array, p, of length 3 containing the probabilities of stat[1] or more, stat[2] or more, or stat[3] or more monotonic sequences.
If stat[0] is less than 1, p[0] is set to NaN (not a number).
Synopsis with Optional Arguments
#include <imsls.h>
float *imsls_f_noether_cyclical_trend (int n_observations, float x[],
IMSLS_FUZZ, float fuzz,
IMSLS_STAT, int **stat,
IMSLS_STAT_USER, int stat[],
IMSLS_N_MISSING, int *n_missing,
IMSLS_RETURN_USER, float p[],
0)
Optional Arguments
IMSLS_FUZZ, float fuzz (Input)
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 value for fuzz is 0.0. 
IMSLS_STAT, int **stat (Output)
Address of a pointer to an internally allocated array of length 6 containing the following statistics:
Row
Statistics
stat[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.
stat[1]
The number of monotonic sequences of length three in the set defined by stat[0].
stat[2]
The number of nonmonotonic sequences where tied threesomes are counted as nonmonotonic.
stat[3]
The number of monotonic sequences where tied threesomes are counted as monotonic.
stat[4]
The number of middle observations eliminated because they were tied in forming the stat[0] sequences.
stat[5]
The number of tied sequences found in forming the stat[2] and stat[3] sequences. A sequence is called a tied sequence if the middle element is tied with either of the two other elements.
IMSLS_STAT_USER, int stat[] (Output)
Storage for array stat is provided by the user.
See IMSLS_STAT.
IMSLS_N_MISSING, int *n_missing (Output)
Number of missing values in X.
IMSLS_RETURN_USER, float p[] (Input)
User allocated array of length 3 containing the return values.
Description
Routine imsls_f_noether_cyclical_trend 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, stat[1], stat[2], and stat[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 stat[1], tied middle observations are eliminated, and a new set of size 3 is obtained by using the next observation in the sample. In stat[2], the original set of size three is used, and tied middle observations are counted as nonmonotonic. In stat[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 p[0] (or p[1] or p[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.
 
#include <imsls.h>
#include <stdio.h>
int main()
{
float *pvalue=NULL;
int nobs = 1000, nmiss, *stat = NULL;
float *x = NULL;
imsls_random_seed_set(123457);
x = imsls_f_random_uniform(nobs, 0);
pvalue = imsls_f_noether_cyclical_trend(nobs, x,
IMSLS_STAT, &stat,
IMSLS_N_MISSING, &nmiss,
0);
imsls_f_write_matrix("P", 0, 2, pvalue, 0);
imsls_i_write_matrix("STAT", 0, 5, stat, 0);
printf("\n n missing = %d\n", nmiss);
}
Output
 
P
0 1 2
0.6979 0.6979 0.6979
STAT
0 1 2 3 4 5
333 107 107 107 0 0
n missing = 0