Learn R Programming

lawstat (version 2.4.1)

bartels.test: Ranked Version of von Neumann's Ratio Test for Randomness

Description

This function performs the Bartels test for randomness which is based on the ranked version of von Neumann's ratio (RVN). Users can choose whether to test against two-sided, negative or positive correlation. NAs from the data are omitted.

Usage

bartels.test(y, alternative = c("two.sided", "positive.correlated", 
             "negative.correlated"))

Arguments

y
a numeric vector of data values.
alternative
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "negative.correlated" or "positive.correlated".

Value

  • A list with the following components.
  • statisticthe value of the standardized Bartels statistic.
  • parameterRVN Ratio.
  • p.valuethe p-value for the test.
  • data.namea character string giving the names of the data.
  • alternativea character string describing the alternative hypothesis.

References

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

See Also

runs.test

Examples

Run this code
## Simulate 100 observations from an autoregressive model of 
## the first order AR(1)
y = arima.sim(n = 100, list(ar = c(0.5)))

## Test y for randomness
bartels.test(y)

## Sample Output
##
##        Bartels Test - Two sided
## data:  y
## Standardized Bartels Statistic -4.4929, RVN Ratio =
## 1.101, p-value = 7.024e-06

Run the code above in your browser using DataLab