In many applications of statistical methods, it is assumed that the response variable is a sum of several factors and a random noise. In a real world this may not be an appropriate model. For example, some patients may react differently to the same drug treatment or the effect of fertilizer may be influenced by the type of a soil. There might exist an interaction between factors.

If there is more than one observation per cell then standard ANOVA techniques may be applied. Unfortunately, in many cases it is infeasible to get more than one observation taken under the same conditions. For instance, it is not logical to ask the same student the same question twice.

Six tests of additivity hypothesis (under various alternatives) have been included in this package: Tukey test, modified Tukey test, Johnson-Graybill test, LBI test, Mandel test and Tusell test.

Let us generate 10 random subjects, 10 random treatmeants and combine them into a dataset (with no interaction):

```
require(additivityTests)
```

```
## Loading required package: additivityTests
```

```
set.seed(123)
subjects = rnorm(10)
treatments = rnorm(10)
noise = rnorm(100)/100
Y = matrix(rep(subjects,10), 10, 10) + matrix(rep(treatments, each=10), 10, 10) + noise
```

The tests should **not** reject the additive hypothesis:

```
tukey.test(Y)
```

```
##
## Tukey test on 5% alpha-level:
##
## Test statistic: 2.016
## Critival value: 3.96
## The additivity hypothesis cannot be rejected.
```

```
mandel.test(Y)
```

```
##
## Mandel test on 5% alpha-level:
##
## Test statistic: 1.394
## Critival value: 2.013
## The additivity hypothesis cannot be rejected.
```

```
lbi.test(Y)
```

```
##
## Locally Best Invariant test on 5% alpha-level:
##
## Test statistic: 0.2316
## Critival value: 0.2729
## The additivity hypothesis cannot be rejected.
```

```
tusell.test(Y)
```

```
##
## Tusell test on 5% alpha-level:
##
## Test statistic: 2.833e-13
## Critival value: 5.281e-16
## The additivity hypothesis cannot be rejected.
```

```
johnson.graybill.test(Y)
```

```
##
## Johnson and Graybill test on 5% alpha-level:
##
## Test statistic: 0.3252
## Critival value: 0.4375
## The additivity hypothesis cannot be rejected.
```

```
mandel.test(Y)
```

```
##
## Mandel test on 5% alpha-level:
##
## Test statistic: 1.394
## Critival value: 2.013
## The additivity hypothesis cannot be rejected.
```

```
mtukey.test(Y, correction=2, Nboot=1000)
```

```
##
## Modified Tukey test (small sample size correction, type 2) on 5% alpha-level:
##
## Test statistic: 0.5091
## Critival value: 0.9232
## The additivity hypothesis cannot be rejected.
```

Now, the extra effect will be added to the last 5 subjects. The tests **should** reject the additive hypothesis:

```
Y[1:5,] = Y[1:5,] + 10*rep(treatments, each=5)
tukey.test(Y)
```

```
##
## Tukey test on 5% alpha-level:
##
## Test statistic: 134.2
## Critival value: 3.96
## The additivity hypothesis was rejected.
```

```
mandel.test(Y)
```

```
##
## Mandel test on 5% alpha-level:
##
## Test statistic: 3377187
## Critival value: 2.013
## The additivity hypothesis was rejected.
```

```
lbi.test(Y)
```

```
##
## Locally Best Invariant test on 5% alpha-level:
##
## Test statistic: 1
## Critival value: 0.2704
## The additivity hypothesis was rejected.
```

```
tusell.test(Y)
```

```
##
## Tusell test on 5% alpha-level:
##
## Test statistic: 1.548e-57
## Critival value: 5.424e-16
## The additivity hypothesis was rejected.
```

```
johnson.graybill.test(Y)
```

```
##
## Johnson and Graybill test on 5% alpha-level:
##
## Test statistic: 1
## Critival value: 0.4382
## The additivity hypothesis was rejected.
```

```
mandel.test(Y)
```

```
##
## Mandel test on 5% alpha-level:
##
## Test statistic: 3377187
## Critival value: 2.013
## The additivity hypothesis was rejected.
```

```
mtukey.test(Y, correction=2, Nboot=1000)
```

```
##
## Modified Tukey test (small sample size correction, type 2) on 5% alpha-level:
##
## Test statistic: 432.9
## Critival value: 1.152
## The additivity hypothesis was rejected.
```

Simecek, Petr and Simeckova, Marie. “Modification of Tukey's additivity test.” Journal of Statistical Planning and Inference (2012). [ScienceDirect] [arXiv]

Rasch, Dieter, et al. “Tests of additivity in mixed and fixed effect two-way ANOVA models with single sub-class numbers.” Statistical Papers 50.4 (2009): 905-916. [Springer]