kernlab (version 0.9-7)

kmmd: Kernel Maximum Mean Discrepancy.

Description

The Kernel Maximum Mean Discrepancy kmmd performs a non-parametric distribution test.

Usage

## S3 method for class 'matrix':
kmmd(x, y, kernel="rbfdot",kpar="automatic", alpha = 0.05, asymptotic = FALSE,  replace = TRUE, ntimes = 150, frac = 1,  ...)

## S3 method for class 'kernelMatrix': kmmd(x, y, Kxy, alpha = 0.05, asymptotic = FALSE, replace = TRUE, ntimes = 100, frac = 1, ...)

## S3 method for class 'list': kmmd(x, y, kernel="rbfdot",kpar="automatic", alpha = 0.05, asymptotic = FALSE, replace = TRUE, ntimes = 150, frac = 1, ...)

Arguments

x
data values, in a matrix, list, or kernelMatrix
y
data values, in a matrix, list, or kernelMatrix
Kxy
kernlMatrix between $x$ and $y$ values (only for the kernelMatrix interface)
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. kernlab provides the most popular kernel functions which can
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 :
  • sigmainverse kernel width for the Radial Basis
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.

Value

  • An S4 object of class kmmd containing the results of whether the H0 hypothesis is rejected or not. H0 being that the samples $x$ and $y$ come from the same distribution. The object contains the following slots :
  • H0is H0 rejected (logical)
  • AsympH0is H0 rejected according to the asymptotic bound (logical)
  • kernelfthe kernel function used.
  • mmdstatsthe test statistics (vector of two)
  • Radboundthe Rademacher bound
  • Asymboundthe asymptotic bound
  • see kmmd-class for more details.

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.

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 http://www.kyb.mpg.de/publications/attachments/mmd_final_4193[1].pdf

See Also

ksvm

Examples

Run this code
# create data
x <- matrix(runif(300),100)
y <- matrix(runif(300)+1,100)


mmdo <- kmmd(x, y)

mmdo

Run the code above in your browser using DataCamp Workspace