mmd_test {Ecume} R Documentation

## Perform the Maximum Mean Discrepancy unbiased bootstrap test

### Description

Maximum Mean Discrepancy Unbiased Test

### Usage

```mmd_test(
x,
y,
kernel = "rbfdot",
type = ifelse(min(nrow(x), nrow(y)) < 1000, "unbiased", "linear"),
null = c("permutation", "exact"),
iterations = 10^3,
frac = 1,
...
)
```

### Arguments

 `x` d-dimensional samples from the first distribution `y` d-dimensional samples from the first distribution `kernel` A character that must match a known kernel. See details. `type` Which statistic to use. One of 'unbiased' or 'linear'. See Gretton et al for details. Default to 'unbiased' if the two vectors are of length less than `1000` and to 'linear' otherwise. `null` How to asses the null distribution. This can only be set to exact if the `type` is 'unbiased' and the `kernel` is 'rbf'. `iterations` How many iterations to do to simulate the null distribution. Default to 10^4. Only used if `null` is 'permutations' `frac` For the linear statistic, how many points to sample. See details. `...` Further arguments passed to kernel functions

### Details

This computes the MMD^2u unbiased statistic or the MMDl linear statistic from Gretton et al. The code relies on the pairwise_kernel function from the python module sklearn. To list the available kernels, see the examples.

### Value

A list containing the following components:

• statistic the value of the test statistic.

• p.value the p-value of the test.

### References

Gretton, A., Borgwardt, K., Rasch, M. J., Schölkopf, B., & Smola, A. (2012). A Kernel Two-Sample Test Journal of Machine Learning Research (2012)

### Examples

```x <- matrix(rnorm(1000, 0, 1), ncol = 10)
y <- matrix(rnorm(1000, 0, 2), ncol = 10)
mmd_test(x, y)
mmd_test(x, y, type = "linear")
x <- matrix(rnorm(1000, 0, 1), ncol = 10)
y <- matrix(rnorm(1000, 0, 1), ncol = 10)
# Set iterations to small number for runtime
# Increase for more accurate results
mmd_test(x, y, iterations = 10^2)
```

[Package Ecume version 0.9.1 Index]