test2.2018bbw: Test for Equality of Two Distributions by Blumberg, Bhaumik,...

Description Usage References Examples

View source: R/stat_test2.2018bbw.R

Description

Test for Equality of Two Distributions by Blumberg, Bhaumik, and Walker (2018)

Usage

1
test2.2018bbw(x, label)

References

\insertRef

blumberg_testing_2018DAS

Examples

 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
30
31
32
33
## small test for CRAN submission
dat1 <- matrix(rnorm(60, mean= 1), ncol=2) # group 1 : 30 obs of mean  1
dat2 <- matrix(rnorm(50, mean=-1), ncol=2) # group 2 : 25 obs of mean -1

dmat <- as.matrix(dist(rbind(dat1, dat2)))  # Euclidean distance matrix
lab  <- c(rep(1,30), rep(2,25))             # corresponding label

test2.2018bbw(dmat, lab)                    # run the code !

## Not run: 
## WARNING: computationally heavy. 
#  Let's compute empirical Type 1 error at alpha=0.05
niter = 496  
pvals = rep(0,niter)
for (i in 1:niter){
  dat = matrix(rnorm(300),ncol=3)
  lab = c(rep(1,60), rep(2,40))
  pvals[i] = test2.2018bbw(as.matrix(dist(dat)), lab)$p.value
  print(paste("iteration ",i," complete..",sep=""))
}
print(paste("* Empirical Type 1 Error : ",sum(pvals<=0.05)/niter,sep=""))

#  Visualize the above at multiple significance levels
alphas = seq(from=0.001, to=0.999, length.out=100)
errors = rep(0,100)
for (i in 1:100){
   errors[i] = sum(pvals<=alphas[i])/niter
}
plot(alphas, errors, "b", main="Empirical Type 1 Errors", 
     xlab="alpha", ylab="error", lwd=2)
abline(0,1, lwd=2, col="red")

## End(Not run)

kisungyou/DAS documentation built on Jan. 6, 2020, 7:09 a.m.