##################################################
# Testing function MkStat
##################################################
x <- ExtractAmax(flow~date, flowStJohn, tol = 365)
## create autocorrelated time series
id <- as.integer(rank(x$flow, 'first'))
u <- (seq(88)-.5)/88
y <- qnorm(u)[id]
for(ii in 2:length(y))
y[ii] <- 0.4 * y[ii-1] + y[ii] + 1/88
out <- MkStat(x$flow)
expect_equal(signif(out), c(346, 76958 , 0.213635))
out <- MkStat(y, id = combn(length(y),2), pval = FALSE)
expect_equal(signif(out), 454)
##################################################
# Testing function SampleBlock
##################################################
out <- SampleBlock(1:11,3)
expect_equal(length(out), 11)
expect_equal(diff(out[1:3]), c(1,1))
expect_equal(diff(out[4:6]), c(1,1))
expect_true(all(is.finite(out)))
##################################################
# Testing function MkStat
##################################################
## There is no significant correlation
out <- MKendall(x$flow)
expect_equal(signif(c(out$stat,out$pvalue)), c(346, 0.213635))
out <- MKendall(y)
expect_equal(signif(out$stat), 454)
expect_equal(out$block, 3)
y[1] <- NA
expect_error(MKendall(y))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.