# permutationTest: Monte Carlo Permutation Test for Paired Individual Scores In surveillance: Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

## Description

As test statistic the difference between mean `scores` from model A and mean `scores` from model B is used. Under the null hypothesis of no difference, the actually observed difference between mean scores should not be notably different from the distribution of the test statistic under permutation. As the computation of all possible permutations is only feasible for small datasets, a random sample of permutations is used to obtain the null distribution. The resulting p-value thus depends on the `.Random.seed`.

## Usage

 ```1 2``` ```permutationTest(score1, score2, nPermutation = 9999, plot = FALSE, verbose = FALSE) ```

## Arguments

 `score1, score2` numeric vectors of scores to compare `nPermutation` number of random permutations to conduct `plot` logical indicating if a `truehist` of the `nPermutation` permutation test statistics should be plotted with a vertical line marking the observed difference of the means. To customize the histogram, `plot` can also be a list of arguments for `truehist` replacing internal defaults. `verbose` logical indicating if the results should be printed in one line.

## Details

For each permutation, we first randomly assign the membership of the n individual scores to either model A or B with probability 0.5. We then compute the respective difference in mean for model A and B in this permuted set of scores. The Monte Carlo p-value is then given by (1 + #permuted differences larger than observed difference (in absolute value)) / (1 + `nPermutation`).

## Value

a list of the following elements:

 `diffObs` observed difference in mean scores, i.e., `mean(score1) - mean(score2)` `pVal.permut` p-value of the permutation test `pVal.t` p-value of the corresponding `t.test(score1, score2, paired=TRUE)`

## Author(s)

Michaela Paul with contributions by Sebastian Meyer

`scores` to obtain individual scores for `oneStepAhead` predictions from a model.

Package coin for a comprehensive permutation test framework, specifically its function `symmetry_test` to compare paired samples.

## Examples

 `1` ```permutationTest(rnorm(50, 1.5), rnorm(50, 1), plot = TRUE) ```

### Example output

```Loading required package: sp
This is surveillance 1.14.0. For overview type 'help(surveillance)'.
\$diffObs
[1] 0.3786282

\$pVal.permut
[1] 0.0795

\$pVal.t
[1] 0.07449059
```

surveillance documentation built on July 25, 2018, 1:01 a.m.