Description Details Author(s) References Examples
The cross-match test is an exact, distribution free test of equality of 2 high dimensional multivariate distributions.
Package: | crossmatch |
Type: | Package |
Version: | 1.3-1 |
Date: | 2012-06-16 |
License: | GPL-2 |
LazyLoad: | yes |
For the cross-match test, use the function crossmatchtest
.
Ruth Heller, Paul Rosenbaum, Dylan Small. Maintainer: Ruth Heller <ruheller@post.tau.ac.il>
Rosenbaum, P.R. (2005), An exact distribution-free test comparing two multivariate distributions based on adjacency, Journal of the Royal Statistical Society: Series B (Statistical Methodology), 67, 4, 515-530.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## The example in Section 2 of the article (see References)
#The data consists of 2 outcomes measured on 9 treated cases and 9 controls:
dat <- rbind(c(0.47,0.39,0.47,0.78,1,1,0.54,1,0.38,1,0.27,0.63,0.22,0,-1,-0.42,-1,-1),
c(0.03,0.11,0.16,-0.1,-0.05,0.16,0.12,0.4,0.04,0.71,0.01,0.21,-0.18,-0.08 ,-0.35,0.26,-0.6,-1.0))
z <- c(rep(0,9),rep(1,9))
X <- t(dat)
## Rank based Mahalanobis distance between each pair:
X <- as.matrix(X)
n <- dim(X)[1]
k <- dim(X)[2]
for (j in 1:k) X[,j] <- rank(X[,j])
cv <- cov(X)
vuntied <- var(1:n)
rat <- sqrt(vuntied/diag(cv))
cv <- diag(rat)%*%cv%*%diag(rat)
out <- matrix(NA,n,n)
library(MASS)
icov <- ginv(cv)
for (i in 1:n) out[i,] <- mahalanobis(X,X[i,],icov,inverted=TRUE)
dis <- out
## The cross-match test:
crossmatchtest(z,dis)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.