1 |
m1 |
|
m2 |
|
tr |
|
nullv |
|
plotit |
|
SEED |
|
pop |
|
fr |
|
nboot |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (m1, m2, tr = 0.5, nullv = rep(0, ncol(m1)), plotit = TRUE,
SEED = TRUE, pop = 1, fr = 0.8, nboot = 600)
{
if (!is.matrix(m1))
stop("m1 is not a matrix")
if (!is.matrix(m2))
stop("m2 is not a matrix")
if (ncol(m1) != ncol(m2))
stop("number of columns for m1 and m2 are not equal")
n1 <- nrow(m1)
n2 <- nrow(m2)
if (SEED)
set.seed(2)
data1 <- matrix(sample(n1, size = n1 * nboot, replace = T),
nrow = nboot)
data2 <- matrix(sample(n2, size = n2 * nboot, replace = T),
nrow = nboot)
bcon <- matrix(NA, ncol = ncol(m1), nrow = nboot)
for (j in 1:nboot) bcon[j, ] <- mdifloc(m1[data1[j, ], ],
m2[data2[j, ], ], est = lloc, tr = tr)
tvec <- mdifloc(m1, m2, est = lloc, tr = tr)
tempcen <- apply(bcon, 1, mean)
smat <- var(bcon - tempcen + tvec)
temp <- bcon - tempcen + tvec
bcon <- rbind(bcon, nullv)
dv <- mahalanobis(bcon, tvec, smat)
bplus <- nboot + 1
sig.level <- 1 - sum(dv[bplus] >= dv[1:nboot])/nboot
if (plotit && ncol(m1) == 2) {
if (pop == 2)
rdplot(mdif, fr = fr)
if (pop == 1) {
plot(mdif[, 1], mdif[, 2], xlab = "VAR 1", ylab = "VAR 2",
type = "n")
points(mdif[, 1], mdif[, 2], pch = ".")
points(center[1], center[2], pch = "o")
points(0, 0, pch = "+")
}
if (pop == 3)
akerdmul(mdif, fr = fr)
}
list(p.value = sig.level, center = tvec)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.