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")
## Default S3 method:
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.
Details
Missing values are by default removed.
The RVN test statistic is
RVN=∑(R_i-R_{i+1})^2 / ∑(R_i-(n+1)/2)^2
where R_i=rank(X_i), i=1,...,n. It is known that (RVN-2)/σ is asymptotically standard normal, where σ^2=[4(n-2)(5n^2-2n-9)]/[5n(n+1)(n-1)^2].
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.
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.
# 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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SciencesPo)
Loading required package: ggplot2
initializing ... done
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SciencesPo/Bartels.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Bartels
> ### Title: Bartels Rank Test of Randomness
> ### Aliases: Bartels Bartels.default
> ### Keywords: Tests
>
> ### ** Examples
>
> # 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")
Bartels Ratio Test
data: tourists
statistic = -3.6453, n = 13, p-value = 0.0000000121
alternative hypothesis: trend
>
>
>
>
>
>
> dev.off()
null device
1
>