# randomShuffleTest: Perform the random shuffle test In JeremySilver/RandomThinning: Random Thinning Tests and Auxiliary Functions

## Description

Perform the random shuffle test

## Usage

 ```1 2``` ```randomShuffleTest(ts, its = NULL, blockLength = 1, p = 5, n = 1000, alpha = 0.05, returnExtraInfo = FALSE) ```

## Arguments

 `ts` A time-series (a numeric vector) `its` Indices of which bin the values of x correspond to (a numeric vector of integers between 1 and p). This is optional, and taken to be cyclical by default. `blockLength` Shuffle the order of blocks of this length (a positive integer between 1 and less than `length(ts)` ). If `blockLength` is equal to 1, then the series is shuffled randomly. If blockLength is greater than 1, blocks of this length will be shuffled. The `blockLength` should be much less than `length(ts)` and should be co-prime with `p`. `p` Length of the period to test for (a positive integer) `n` Number of resamples to use in the random shuffle test (a positive integer) `alpha` P-value threshold to use when calculating the power (a positive scalar between 0 and 1, although it is recommended to be around 0.05) `returnExtraInfo` Logical value - if `TRUE`, the function will return extra information (the value of the range test statistic, the mean per bin, the departures within each bin from the mean value, and a confidence interval on the p-value). If `FALSE`, only the p-value is returned.

## Value

This depends on the value of `returnExtraInfo`: - if `returnExtraInfo` is `FALSE` (the default), the function returns the p-value only - if `returnExtraInfo` is `TRUE`, the function returns a list with the p-value, the value of the range test statistic, the mean per bin, the departures within each bin from the mean value, and a confidence interval on the p-value

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```## Generate a random time-series: ## - length = 1000 ## - signal period = 8 ## - signal to noise ratio = 0.2 set.seed(42) x <- rep(rnorm(8)*0.2,length.out = 1000) + rnorm(1000) randomShuffleTest(ts = x, p = 8, n = 1000, blockLength = 10, returnExtraInfo = TRUE) ## compare with periods either too short or too long: randomShuffleTest(ts = x, p = 7, n = 1000, blockLength = 10) randomShuffleTest(ts = x, p = 9, n = 1000, blockLength = 10) ```

JeremySilver/RandomThinning documentation built on May 27, 2017, 12:02 a.m.