Performes the non-parametric Wald-Wolfowitz test for independence and stationarity.
ww.test(x)
An object of class "htest"
a character string indicating the chosen test
a character string giving the name(s) of the data
the Wald-Wolfowitz z-value
a character string describing the alternative hypothesis
the p-value for the test
a vector or a time series object of class "ts"
Let \(x_1, x_2, ..., x_n\) denote the sampled data, then the test statistic of the Wald-Wolfowitz test is calculated as:
$$R = \sum_{i=1}^{n-1} x_i x_{i+1} + x_1 x_n$$
The expected value of R is:
$$E(R) = \frac{s_1^2 - s_2}{n - 1}$$
The expected variance is:
$$V(R) = \frac{s_2^2 - s_4}{n - 1} - E(R)^2 + \frac{s_1^4 - 4 s_1^2 s_2 + 4 s_1 s_3 + s_2^2 - 2 s_4}{(n - 1) (n - 2)}$$
with:
$$s_t = \sum_{i=1}^{n} x_i^t, ~~ t = 1, 2, 3, 4$$
For \(n > 10\) the test statistic is normally distributed, with:
$$z = \frac{R - E(R)}{\sqrt{V(R)}}$$
ww.test calculates p-values from the standard normal distribution for the two-sided case.
R. K. Rai, A. Upadhyay, C. S. P. Ojha and L. M. Lye (2013), Statistical analysis of hydro-climatic variables. In: R. Y. Surampalli, T. C. Zhang, C. S. P. Ojha, B. R. Gurjar, R. D. Tyagi and C. M. Kao (ed. 2013), Climate change modelling, mitigation, and adaptation. Reston, VA: ASCE. doi = 10.1061/9780784412718.
A. Wald and J. Wolfowitz (1943), An exact test for randomness in the non-parametric case based on serial correlation. Annual Mathematical Statistics 14, 378--388.
WMO (2009), Guide to Hydrological Practices. Volume II, Management of Water Resources and Application of Hydrological Practices, WMO-No. 168.
ww.test(nottem)
ww.test(Nile)
set.seed(200)
x <- rnorm(100)
ww.test(x)
Run the code above in your browser using DataLab