# rank.test: The Rank Test of Statistical Independence In spgs: Statistical Patterns in Genomic Sequences

## Description

Test for a trend in a data series by comparing the number of increasing pairs in the series with the number expected in an i.i.d. series.

## Usage

 `1` ```rank.test(x) ```

## Arguments

 `x` a numeric vector or univariate time series.

## Details

Perform a test for trend based on the number of increasing ordered pairs in a data series. Consider pairs of the form (x(i), x(j)), where i<j. An increasing pair is any such pair for which x_i<x_j. This function counts the number of increasing pairs in the data, standardises it to have mean 0 and variance 1 and asymptotically tests it against a standard normal distribution. the test statistic is:

R = (pairs-mu)/sigma, where
pairs is the number of increasing pairs in the data,
mu = n*(n-1)/4,
sigma = sqrt(n*(n-1)*(2*n+5)/72) and
n is the number of data points in the series.

The test is set up as follows:

H0: the data series is i.i.d. (not trending)
H1: the data series is not i.i.d. (trending)

## Value

A list with class "htest" containing the following components:

 `statistic` the value of the test statistic. `p.value` the p-value of the test. `method` a character string indicating what type of test was performed. `data.name` a character string giving the name of the data. `pairs` the number of increasing pairs counted in the data series. `n` the number of points in the data series. `mu` The expected number of increasing pairs that would be seen in an i.i.d. series. `sigma` The standard deviation of the number of increasing pairs that would be seen in an i.i.d. series.

## Warning

If the spgs shared object was successfully compiled with support for a 64-bit unsigned integer type, then the following line should yield the value 0:

rank.test(1:92683)\$pairs-2^32-55607

if not, then the package is only using 32-bit integer arithmetic for computing the rank test statistic and this will restrict `rank.test` to analysing series whose length is at most 92682. In this case, attempting to apply `rank.test` to a series longer than 92682 will result in a warning about an integer overflow having occurred and the results of the test should not be trusted.

## Note

Missing values are not handled.

Points followed by a point having the exact same value are removed from the data series before computing the test statistic.

This test is useful for detecting linear trends in data series.

## Author(s)

Andrew Hart and Servet Mart<ed>nez

## References

Brockwell, Peter J., Davis, Richard A. (2002) Introduction to Time Series and Forecasting. Springer Texts in Statistics, Springer-Verlag, New York.

`diffsign.test`, `turningpoint.test`, `lb.test`, `markov.test`, `diid.test`

## Examples

 ```1 2 3``` ```#Generate an IID standard normal sequence n <- rnorm(1000) rank.test(n) ```

### Example output

```	Rank test of independence

data:  n
R = -0.079061, p-value = 0.937
```

spgs documentation built on July 21, 2017, 9:02 a.m.