Learn R Programming

randtests (version 1.0.1)

runs.test: Wald-Wolfowitz Runs Test

Description

Performs the Wald-Wolfowitz runs test of randomness for continuous data.

Usage

runs.test(x, alternative, threshold, pvalue, plot)

Arguments

x

a numeric vector containing the observations

alternative

a character string with the alternative hypothesis. Must be one of "two.sided" (default), "left.sided" or "right.sided". You can specify just the initial letter.

threshold

the cut-point to transform the data into a dichotomous vector

pvalue

a character string specifying the method used to compute the p-value. Must be one of normal (default), or exact.

plot

a logic value to select whether a plot should be created. If 'TRUE', then the graph will be plotted.

Value

A list with class "htest" containing the components:

statistic

the value of the normalized statistic test.

parameter

a vector with the sample size, and the values of \(n_1\) and \(n_2\).

p.value

the p-value of the test.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating the test performed.

data.name

a character string giving the name of the data.

runs

the total number of runs (not shown on screen).

mu

the mean value of the statistic test (not shown on screen).

var

the variance of the statistic test (not shown on screen).

Details

Data is transformed into a dichotomous vector according as each values is above or below a given threshold. Values equal to the level are removed from the sample.

The default threshold value used in applications is the sample median which give us the special case of this test with \(n_1=n_2\), the runs test above and below the median.

The possible alternative values are "two.sided", "left.sided" and "right.sided" define the alternative hypothesis. By using the alternative "left.sided" the null of randomness is tested against a trend. By using the alternative "right.sided" the null hypothesis of randomness is tested against a first order negative serial correlation.

References

Brownlee, K. A. (1965). Statistical Theory and Methodology in Science and Engineering, 2nd ed. New York: Wiley.

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

Wald, A. and Wolfowitz, J. (1940). On a test whether two samples are from the same population, The Annals of Mathematical Statistics 11, 147--162. doi:10.1214/aoms/1177731909. https://projecteuclid.org/journals/annals-of-mathematical-statistics/volume-11/issue-2/On-a-Test-Whether-Two-Samples-are-from-the-Same/10.1214/aoms/1177731909.full

Examples

Run this code
# NOT RUN {
##
## Example 1
## Data from example in Brownlee (1965), p. 223.
## Results of 23 determinations, ordered in time, of the density of the earth.
##
earthden <- c(5.36, 5.29, 5.58, 5.65, 5.57, 5.53, 5.62, 5.29, 5.44, 5.34, 5.79, 
5.10, 5.27, 5.39, 5.42, 5.47, 5.63, 5.34, 5.46, 5.30, 5.75, 5.68, 5.85)
runs.test(earthden)


##
## Example 2
## Sweet potato yield per acre, harvested in the United States, between 1868 and 1937.
## Data available in this package.
##
data(sweetpotato)
runs.test(sweetpotato$yield)
# }

Run the code above in your browser using DataLab