|
IDL Analyst Reference Guide: Nonparametric Statistics |
|
The IMSL_CSTRENDS function performs the Cox and Stuart sign test for trends in location and dispersion.
| Note This routine requires an IDL Analyst license. For more information, contact your ITT Visual Information Solutions sales or technical support representative. |
Result = IMSL_CSTRENDS(x [, /DOUBLE] [, DISPERSION=array] [, FUZZ=value] [, NMISSING=variable] [, NSTAT=variable])
One-dimensional array of length 8 containing the probabilities.
The first four elements of Result are computed from two groups of observations.
The last four elements of Result are computed from three groups of observations.
One-dimensional array containing the data in chronological order.
If present and nonzero, double precision is used.
A one-dimensional array of length 2. If Dispersion is set, the Cox and Stuart tests for trends in dispersion are computed. Otherwise, as default, the Cox and Stuart tests for trends in location are computed.
k = Dispersion(0) is the number of consecutive x elements to be used to measure dispersion. If ids = Dispersion(1) is zero, the range is used as a measure of dispersion. Otherwise, the centered sum of squares is used.
A nonnegative constant used to determine when elements in x are tied. If |x(i) – x(j)| is less than or equal to Fuzz, x(i) and x(j) are said to be tied. Fuzz must be nonnegative. Default: Fuzz = 0.0.
Named variable into which the number of missing values in x is stored.
Named variable into which the one-dimensional array of length 8 containing the statistics below is stored:
The IMSL_CSTRENDS function tests for trends in dispersion or location in a sequence of random variables depending upon the usage of Dispersion. A derivative of the sign test is used (see Cox and Stuart 1955).
For the location test (Default) with two groups, the observations are first divided into two groups with the middle observation thrown out if there are an odd number of observations. Each observation in group one is then compared with the observation in group two that has the same lexicographical order. A count is made of the number of times a group-one observation is less than (Nstat(0)), greater than (Nstat(1)), or equal to (Nstat(2)), its counterpart in group two. Two observations are counted as equal if they are within Fuzz of one another.
In the three-group test, the observations are divided into three groups, with the center group losing observations if the division is not exact. The first and third groups are then compared as in the two-group case, and the counts are stored in Nstat(4) through Nstat(6).
Probabilities in Result are computed using the binomial distribution with sample size equal to the number of observations in the first group (Nstat(3) or Nstat(7)), and binomial probability p = 0.5.
The dispersion tests (when keyword Dispersion is set) proceed exactly as with the tests for location, but using one of two derived dispersion measures. The input value k = Dispersion(0) is used to define N_ELEMENTS(x)/k groups of consecutive observations starting with observation 1. The first k observations define the first group, the next k observations define the second group, etc., with the last observations omitted if N_ELEMENTS(x) is not evenly divisible by k. A dispersion score is then computed for each group as either the range (ids = 0), or a multiple of the variance (ids ¹ 0) of the observations in the group. The dispersion scores form a derived sample. The tests proceed on the derived sample as above.
Ties are defined as occurring when a group one observation is within Fuzz of its last group counterpart. Ties imply that the probability distribution of x is not strictly continuous, which means that Pr(x1 > x2) ¹ 0.5 under the null hypothesis of no trend (and the assumption of independent identically distributed observations). When ties are present, the computed binomial probabilities are not exact, and the hypothesis tests will be conservative.
In the following, i indexes an observation from group 1, while j indexes the corresponding observation in group 2 (two groups) or group 3 (three groups).
This example illustrates both the location and dispersion tests. The data, which are taken from Bradley (1968), page 176, give the closing price of AT&T on the New York stock exchange for 36 days in 1965. Tests for trends in location (Default), and for trends in dispersion (Dispersion) are performed. Trends in location are found.
x = [9.5, 9.875, 9.25, 9.5, 9.375, 9.0, 8.75, 8.625, 8.0, $ 8.25, 8.25, 8.375, 8.125, 7.875, 7.5, 7.875, 7.875, $ 7.75,7.75, 7.75, 8.0, 7.5,7.5, 7.125, 7.25, 7.25, 7.125, $ 6.75,6.5, 7.0, 7.0, 6.75, 6.625, 6.625,7.125, 7.75] k = 2 ids = 0 pstat = IMSL_CSTRENDS(x, Nstat = nstat) PM, nstat, Title = ' NSTAT' PM, pstat, Title = ' PSTAT' pstat = IMSL_CSTRENDS(x, Nstat = nstat, Dispersion = [k, ids]) PM, nstat, Title = ' NSTAT' PM, pstat, Title = ' PSTAT' NSTAT 0 17 1 18 0 12 0 12 PSTAT 0.999996 7.24792e-05 1.00000 3.81470e-06 1.00000 0.000244141 1.00000 0.000244141 NSTAT 4 3 2 9 4 2 0 6 PSTAT 0.253906 0.910156 0.746094 0.500000 0.343750 0.890625 0.343750 0.890625
IDL Online Help (March 06, 2007)