The function calculates the 2-sided p-value of the Wald-Wolfowitz runs test after dichotomizing the input vector
Numeric vector of data values.
A character string describing the method for the p-value calculation of the runs
This function calculates the 2-sided p-value of the runs.test.
The large sample approximations are an adaption from the codes for
found in the R-packages lawstat and tseries.
The aim of this own was to avoid the heavy footprint of both packages for this small package.
The user can choose the application of a continuity correction to the normal approximation like a SAS implementation http://support.sas.com/kb/33/092.html uses or like SPSS if n<50.
The exact distribution of runs and the p-value based on it are described in the manual of SPSS "Exact tests" to be found f.i. http://www.sussex.ac.uk/its/pdfs/SPSS_Exact_Tests_21.pdf.
pmethod="exact" is chosen and n>30 and n1>12 and n2>12 (see
the continuity corrected version of the normal approximation is used to save time and memory.
Numeric p-value of the 2-sided test.
runs.test() package lawstat
Authors: Wallace Hui, Yulia R. Gel, Joseph L. Gastwirth, Weiwen Miao
runs.test() package tseries
Author: A. Trapletti
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# alternating sequence 1,2,1,2 ... # maybe seen as numeric representation of 'TR','RT' ... # and is used in that way here in this package x <- rep(c(1, 2), 6) runs.pvalue(x, pmethod="normal") # should give 0.002464631 # exact p-value runs.pvalue(x, pmethod="exact") # should give 0.004329004 # # same for 3 numbers (numeric representation of 3 sequences) x <- rep(c(1, 2, 3),4) runs.pvalue(x, pmethod="normal") # should give 0.2502128 # i.e. is seen as compatible with a random sequence! # exact p-value, default i.e. must not given exolicitely runs.pvalue(x) # should give 0.3212121 # i.e. is seen even more as compatible with a random sequence!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.