1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
corfun |
|
nboot |
|
alpha |
|
... |
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 | ##---- 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 (x1, y1, x2, y2, corfun = pbcor, nboot = 599, alpha = 0.05,
...)
{
set.seed(2)
print("Taking bootstrap samples. Please wait.")
data1 <- matrix(sample(length(y1), size = length(y1) * nboot,
replace = TRUE), nrow = nboot)
bvec1 <- apply(data1, 1, corbsub, x1, y1, corfun, ...)
data2 <- matrix(sample(length(y2), size = length(y2) * nboot,
replace = TRUE), nrow = nboot)
bvec2 <- apply(data2, 1, corbsub, x2, y2, corfun, ...)
bvec <- bvec1 - bvec2
bsort <- sort(bvec)
term <- alpha/2
ilow <- round((alpha/2) * nboot)
ihi <- nboot - ilow
ilow <- ilow + 1
corci <- 1
corci[1] <- bsort[ilow]
corci[2] <- bsort[ihi]
pv <- (sum(bvec < 0) + 0.5 * sum(bvec == 0))/nboot
pv = 2 * min(c(pv, 1 - pv))
r1 <- corfun(x1, y1)$cor
r2 <- corfun(x2, y2)$cor
reject <- "NO"
if (corci[1] > 0 || corci[2] < 0)
reject = "YES"
list(r1 = r1, r2 = r2, ci.dif = corci, p.value = pv)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.