Multivariate Non-Parametric Cramer-Test for the Two Sample Problems | GERMAN 0270, Exams of German Philology

Material Type: Exam; Class: LITERARY THEORY; Subject: German; University: University of California - Los Angeles; Term: Spring 2009;

Typology: Exams

Pre 2010

Uploaded on 08/31/2009

koofers-user-fo1
koofers-user-fo1 🇺🇸

8 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Package ‘cramer’
April 17, 2009
Version 0.8-1
Date 2006/06/18
Title Multivariate nonparametric Cramer-Test for the two-sample-problem
Author Carsten Franz <[email protected].de>
Maintainer Carsten Franz <[email protected]>
Depends R (>= 0.65), boot
Imports boot
Description Provides R routine for the so called two-sample Cramer-Test. This not distribution free,
nonparametric two-sample-test can be applied on multivariate data as well as univariate data. It
offers two possiblities to approximate the critical value both of which are included in this
package.
License GPL (>= 2)
Repository CRAN
Date/Publication 2006-06-19 06:58:24
Rtopics documented:
cramer.test.......................................... 2
Index 6
1
pf3
pf4
pf5

Partial preview of the text

Download Multivariate Non-Parametric Cramer-Test for the Two Sample Problems | GERMAN 0270 and more Exams German Philology in PDF only on Docsity!

Package ‘cramer’

April 17, 2009

Version 0.8-

Date 2006/06/

Title Multivariate nonparametric Cramer-Test for the two-sample-problem

Author Carsten Franz

Maintainer Carsten Franz

Depends R (>= 0.65), boot

Imports boot

Description Provides R routine for the so called two-sample Cramer-Test. This not distribution free, nonparametric two-sample-test can be applied on multivariate data as well as univariate data. It offers two possiblities to approximate the critical value both of which are included in this package.

License GPL (>= 2)

Repository CRAN

Date/Publication 2006-06-19 06:58:

R topics documented:

cramer.test.......................................... 2

Index 6

cramer.test Cramer-Test for uni- and multivariate two-sample-problem

Description

Perform Cramér-test for two-sample-problem. Both univariate and multivariate data is possible. For calculation of the critical value Monte-Carlo-bootstrap-methods and eigenvalue-methods are available. For the bootstrap access ordinary and permutation methods can be chosen as well as the number of bootstrap-replicates taken.

Usage

cramer.test(x,y,conf.level=0.95,replicates=1000, sim="ordinary",just.statistic=FALSE, kernel="phiCramer", maxM=2^14, K=160)

Arguments

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 x. conf.level Confidence level of test. The default is conf.level=0.95. sim Type of Monte-Carlo-bootstrap method or eigenvalue method. Possible values are "ordinary" (default) for normal Monte-Carlo-bootstrap, "permutation" for a permutation Monte-Carlo-bootstrap or "eigenvalue" for bootstrap- ping the limit distribution, evaluating the (approximate) eigenvalues being the weights of the limiting chisquared-distribution and using the critical value of this approximation (calculated via fast fourier transform). This method is es- pecially good if the dataset is too large to perform Monte-Carlo-bootstrapping (although it must not be too large so the matrix eigenvalue problem can still be solved). replicates Number of bootstrap-replicates taken to obtain critical value. The default is replicates=1000. When using the eigenvalue method, this variable is un- used. maxM Gives the maximum number of points used for the fast fourier transform. When using Monte-Carlo-bootstrap methods, this variable is unused. K Gives the upper value up to which the integral for the calculation of the distribu- tion function out of the characteristic function (Gurlands formula) is evaluated. The default ist 160. Careful: When increasing K it is necessary to increase maxM as well since the resolution of the points where the distribution function is calculated is 2 π K

Thus, if just K is increased the maximum value, where the distribution function is calculated is lower. When using Monte-Carlo-bootstrap methods, this variable is unused.

Value

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 x observations. n Number of y observations. statistic Value of the Cramér-statistic 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 p-value of the test. result Contains 1 if the hypothesis of equal distributions should not be accepted and 0 otherwise. sim Method used for obtaining the critical value. replicates Number of bootstrap-replicates taken. ev Contains eigenvalues and eigenfunctions when using the eigenvalue-method to obtain the critical value hypdist Contains the via fft reconstructed distribution function under the hypothesis. $x contains the x-values and $Fx the values of the distribution function at the positions.

References

The test and its properties is described in: Baringhaus, L. and Franz, C. (2004) On a new multivariate two-sample test, Journal of Multivariate Analysis, 88, p. 190- Franz, C. (2000) Ein statistischer Test fuer das mehrdimensionale Zweistichproben-Problem, Ger- man, Diploma thesis, University of Hanover. The test of Bahr so far is only mentioned in: Bahr, R. (1996) Ein neuer Test fuer das mehrdimensionale Zwei-Stichproben-Problem bei allge- meiner Alternative, German, Ph.D. thesis, University of Hanover. The eigenvalue method will be described in a forthcoming article.

Examples

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(1-exp(-x/2)) x<-rnorm(20,mean=0,sd=1) y<-rnorm(50,mean=0,sd=2) cramer.test(x,y,sim="eigenvalue",kernel="phiBahr")