Description Usage Arguments Details Value References Examples
Perform Cramertest for twosampleproblem. Both univariate and multivariate data is possible. For calculation of the critical value MonteCarlobootstrapmethods and eigenvaluemethods are available. For the bootstrap access ordinary and permutation methods can be chosen as well as the number of bootstrapreplicates taken.
1 2 3  cramer.test(x,y,conf.level=0.95,replicates=1000,
sim="ordinary",just.statistic=FALSE,
kernel="phiCramer", maxM=2^14, K=160)

x 
First set of observations. Either in vector form (univariate) or in a matrix with one observation per row (multivariate). 
y 
Second set of observations. Same dimension as 
conf.level 
Confidence level of test. The default is 
sim 
Type of MonteCarlobootstrap method or eigenvalue method. Possible values are

replicates 
Number of bootstrapreplicates taken to obtain critical value. The default is 
maxM 
Gives the maximum number of points used for the fast fourier transform. When using MonteCarlobootstrap methods, this variable is unused. 
K 
Gives the upper value up to which the integral for the calculation of the
distribution function out of the characteristic function (Gurlands formula) is
evaluated. The default ist 160. Careful: When increasing 2 PI/K. Thus, if just 
just.statistic 
Boolean variable. If 
kernel 
Characterstring giving the name of the kernel function. The default is 
The Cramerstatistic is given by
T=mn/(m+n) ( 2/(mn) Sum[i=1..m,j=1..n] phi(X_iY_j^2)  1/(m^2) Sum[i=1..m,j=1..m] phi(X_iX_j^2)  1/(n^2) Sum[i=1..n,j=1..n] phi(Y_iY_j^2) )
\code{}
The function phi is the kernel function mentioned in the Parameters section. The proof that the MonteCarloBootstrap and eigenvalue methods work is given in the reference listed below. Other buildin kernel functions are
phiCramer(z)=z^(1/2)/2
(recommended for location alternatives),
phiBahr(z)=1exp(z/2)
(recommended for dispersion as well as location alternatives),
phiLog(z)=log(1+z)
(preferrably for location alternatives),
phiFracA(z)=11/(1+z)
(preferrably for dispersion alternatives) and
phiFracA(B)=11/(1+z)^2.
(also for dispersion alternatives). A further analysis of the test performance for these kernels will be included in a further publication. The idea of using this statistic is due to L. Baringhaus, University of Hanover.
The returned value is an object of class "cramertest"
, containing the following
components:
method 
Describing the test in words. 
d 
Dimension of the observations. 
m 
Number of 
n 
Number of 
statistic 
Value of the Cramerstatistic for the given observations. 
conf.level 
Confidence level for the test. 
crit.value 
Critical value calculated by bootstrap method, eigenvalue method, respectively. When using the eigenvalue method, the distribution under the hypothesis will be interpolated linearly. 
p.value 
Estimated pvalue of the test. 
result 
Contains 
sim 
Method used for obtaining the critical value. 
replicates 
Number of bootstrapreplicates taken. 
ev 
Contains eigenvalues and eigenfunctions when using the eigenvaluemethod to obtain the critical value 
hypdist 
Contains the via fft reconstructed distribution function under the hypothesis. 
The test and its properties is described in:
Baringhaus, L. and Franz, C. (2004) On a new multivariate twosample test, Journal of Multivariate Analysis, 88, p. 190206
Franz, C. (2000) Ein statistischer Test fuer das mehrdimensionale ZweistichprobenProblem, German, Diploma thesis, University of Hanover.
The test of Bahr so far is only mentioned in:
Bahr, R. (1996) Ein neuer Test fuer das mehrdimensionale ZweiStichprobenProblem bei allgemeiner Alternative, German, Ph.D. thesis, University of Hanover.
The eigenvalue method will be described in a forthcoming article.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  # comparison of two univariate normal distributions
x<rnorm(20,mean=0,sd=1)
y<rnorm(50,mean=0.5,sd=1)
cramer.test(x,y)
# comparison of two multivariate normal distributions with permutation test:
# library "MASS" for multivariate routines (included in package "VR")
# library(MASS)
# x<mvrnorm(n=20,mu=c(0,0),Sigma=diag(c(1,1)))
# y<mvrnorm(n=50,mu=c(0.3,0),Sigma=diag(c(1,1)))
# cramer.test(x,y,sim="permutation")
# comparison of two univariate normal distributions with Bahrs Kernel
phiBahr<function(x) return(1exp(x/2))
x<rnorm(20,mean=0,sd=1)
y<rnorm(50,mean=0,sd=2)
cramer.test(x,y,sim="eigenvalue",kernel="phiBahr")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.