kmmd {kernlab} | R Documentation |
Kernel Maximum Mean Discrepancy.
Description
The Kernel Maximum Mean Discrepancy kmmd
performs
a non-parametric distribution test.
Usage
## S4 method for signature 'matrix'
kmmd(x, y, kernel="rbfdot",kpar="automatic", alpha = 0.05,
asymptotic = FALSE, replace = TRUE, ntimes = 150, frac = 1, ...)
## S4 method for signature 'kernelMatrix'
kmmd(x, y, Kxy, alpha = 0.05,
asymptotic = FALSE, replace = TRUE, ntimes = 100, frac = 1, ...)
## S4 method for signature 'list'
kmmd(x, y, kernel="stringdot",
kpar = list(type = "spectrum", length = 4), alpha = 0.05,
asymptotic = FALSE, replace = TRUE, ntimes = 150, frac = 1, ...)
Arguments
x |
data values, in a |
y |
data values, in a |
Kxy |
|
kernel |
the kernel function used in training and predicting.
This parameter can be set to any function, of class kernel, which computes a dot product between two
vector arguments.
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
kpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed
through the |
alpha |
the confidence level of the test (default: 0.05) |
asymptotic |
calculate the bounds asymptotically (suitable for smaller datasets) (default: FALSE) |
replace |
use replace when sampling for computing the asymptotic bounds (default : TRUE) |
ntimes |
number of times repeating the sampling procedure (default : 150) |
frac |
fraction of points to sample (frac : 1) |
... |
additional parameters. |
Details
kmmd
calculates the kernel maximum mean discrepancy for
samples from two distributions and conducts a test as to whether the samples are
from different distributions with level alpha
.
Value
An S4 object of class kmmd
containing the
results of whether the H0 hypothesis is rejected or not. H0 being
that the samples and
come from the same distribution.
The object contains the following slots :
H0 |
is H0 rejected (logical) |
AsympH0 |
is H0 rejected according to the asymptotic bound (logical) |
kernelf |
the kernel function used. |
mmdstats |
the test statistics (vector of two) |
Radbound |
the Rademacher bound |
Asymbound |
the asymptotic bound |
see kmmd-class
for more details.
Author(s)
Alexandros Karatzoglou
alexandros.karatzoglou@ci.tuwien.ac.at
References
Gretton, A., K. Borgwardt, M. Rasch, B. Schoelkopf and A. Smola
A Kernel Method for the Two-Sample-Problem
Neural Information Processing Systems 2006, Vancouver
https://papers.neurips.cc/paper/3110-a-kernel-method-for-the-two-sample-problem.pdf
See Also
ksvm
Examples
# create data
x <- matrix(runif(300),100)
y <- matrix(runif(300)+1,100)
mmdo <- kmmd(x, y)
mmdo