Performs a test of randomness of a sequence of observations (P.W. Goedhart).

### Options

`PRINT` = string token |
Controls printed output (`results` ); default `resu` |
---|---|

`NULL` = scalar |
Defines the boundary between the two types; default 0 |

### Parameters

`DATA` = variates |
Sequences of observations |
---|---|

`SAVE` = pointers |
To save the number of runs, the number of positive and negative observations and the lower and upper tail probabilities of the test |

### Description

The data are assumed to be in an ordered sequence of observations of two types, *n*_{1} of the first type and *n*_{2} of the second type. A run is defined to be a succession of observations of the same type. A clue to lack of randomness is provided by the total number of runs in the sequence. If the data are in random order, the expected number of runs is 1 + 2*n*_{1}*n*_{2}/(*n*_{1}+*n*_{2}). A low number of runs might indicate positive serial correlation while a high number might arise from negative serial correlation.

The `DATA`

parameter is used to specify the sequence of observations. Observations larger than option `NULL`

are considered to be of the first type (positive) while observation smaller than `NULL`

are of the second type (negative). Missing values and observations that equal `NULL`

are not taken into account. The `PRINT`

option controls printed output, while the `SAVE`

parameter can be used to specify a pointer containing five scalars to save the number of runs, the number of positive observations (that is, those larger than `NULL`

), the number of negative observations and the lower and upper tail probabilities of the number of runs.

Options: `PRINT`

, `NULL`

.

Parameters: `DATA`

, `SAVE`

.

### Method

When the number of observations of type one and two are both smaller than 11, exact left and right tail probabilities are taken from Table 3.1 from Draper & Smith (1981). In other cases a normal approximation with continuity correction is used.

### Action with `RESTRICT`

The `DATA`

variate can be restricted so that the test uses only a subset of the units.

### Reference

Draper & Smith (1981). *Applied Regression Analysis (second edition)*. Wiley, New York.

### See also

Commands for: Basic and nonparametric statistics.

### Example

CAPTION 'RUNTEST example',\ !t('Testing for randomness in a sequence of numbers obtained',\ 'with URAND. Testing for serial correlation in a sequence of',\ 'residuals.'); STYLE=meta,plain CALCULATE uniform = URAND(7453671; 5000) RUNTEST [NULL=0.5] uniform VARIATE [NVALUES=20] time, response; VALUES=!(1...20), * READ response 6.52 5.74 5.39 5.34 5.02 5.42 4.90 5.67 5.06 5.32 3.43 3.81 3.15 3.39 4.03 4.12 3.96 3.93 3.81 3.94 : MODEL response; RESIDUALS=residual FITCURVE [CURVE=exponential] time RUNTEST residual