turningpoint.test: The Turning Point Test of Statistical Independence

View source: R/auxtests.R

turningpoint.testR Documentation

The Turning Point Test of Statistical Independence

Description

Perform a test of statistical independence of a data series by comparing the number of turning points present in the series with the number of turning points expected to be present in an i.i.d. series.

Usage

turningpoint.test(x)

Arguments

x

a numeric vector or univariate time series.

Details

If the data is x[1], x[2], ..., x[n], then there is a turning point at the point i if either x[i-1]<x[i] and x[i]>x[i+1], or x[i-1]>x[i] and x[i]<x[i+1]. this function counts the number of turning points 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

T = (tp-mu)/sigma, where
tp is the number of turning points present in the series,
mu = 2*(n-2)/3,
sigma = sqrt((16*n-29)/90) and
n is the number of data points in the series.

The test is set up as follows:

H_0: the data series is i.i.d. (not trending)
H_1: 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.

n

the number of points in the data series.

mu

The expected number of turning points that would be seen in an i.i.d. series.

sigma

The standard deviation of the number of turning points that would be seen in an i.i.d. series.

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 cyclic/periodic trends in data series.

Author(s)

Andrew Hart and Servet Martínez

References

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

Bienaymé, Irénée-Jules (1874). Sur une question de probabilités. Bull. Math. Soc. Fr. 2, 153-154.

See Also

diffsign.test, rank.test, lb.test, markov.test, diid.test

Examples

#Generate an IID standard normal sequence
n <- rnorm(1000)
turningpoint.test(n)

spgs documentation built on Oct. 3, 2023, 5:07 p.m.