Learn R Programming

SciencesPo (version 1.4.0)

Bartels: Bartels Rank Test of Randomness

Description

Performs Bartels rank test of randomness. The default method for testing the null hypothesis of randomness is two.sided. By using the alternative left.sided, the null hypothesis is tested against a trend. By using the alternative right.sided, the null hypothesis of randomness is tested against a systematic oscillation in the observed data.

Usage

Bartels(x, alternative = "two.sided", pvalue = "normal")
"Bartels"(x, alternative = "two.sided", pvalue = "normal")

Arguments

x
a numeric vector of data values.
alternative
a character string for hypothesis testing method; must be one of two.sided (default), left.sided or right.sided.
pvalue
A method for asymptotic aproximation used to compute the p-value.

Value

statistic
The value of the RVN statistic test and the theoretical mean value and variance of the RVN statistic test.
n
the sample size, after the remotion of consecutive duplicate values.
p.value
the asymptotic p-value.
method
a character string indicating the test performed.
data.name
a character string giving the name of the data.
alternative
a character string describing the alternative.

Details

Missing values are by default removed.

The RVN test statistic is $$RVN=\frac{\sum_{i=1}^{n-1}(R_i-R_{i+1})^2}{\sum_{i=1}^{n}\left(R_i-(n+1)/2\right)^2}$$ where $R_i=rank(X_i), i=1,...,n$. It is known that $(RVN-2)/\sigma$ is asymptotically standard normal, where $\sigma^2=[4(n-2)(5n^2-2n-9)]/[5n(n+1)(n-1)^2]$.

References

Bartels, R. (1982). The Rank Version of von Neumann's Ratio Test for Randomness, Journal of the American Statistical Association, 77(377), 40-46.

Gibbons, J.D. and Chakraborti, S. (2003). Nonparametric Statistical Inference, 4th ed. (pp. 97-98). URL: http://books.google.pt/books?id=dPhtioXwI9cC&lpg=PA97&ots=ZGaQCmuEUq

Examples

Run this code
# Example 5.1 in Gibbons and Chakraborti (2003), p.98.
# Annual data on total number of tourists to the United States for 1970-1982.
 years <- 1970:1982
 tourists <- c(12362, 12739, 13057, 13955, 14123,  15698, 17523,
 18610, 19842, 20310, 22500, 23080, 21916)

 # See it graphically
 qplot(factor(years), tourists)+ geom_point()

# Test the null against a trend
 Bartels(tourists, alternative="left.sided", pvalue="beta")

Run the code above in your browser using DataLab