twoDcorR:

Usage Arguments Examples

Usage

1
twoDcorR(x, y, corfun = wincor, alpha = 0.05, nboot = 500, SEED = TRUE, MC = FALSE)

Arguments

x
y
corfun
alpha
nboot
SEED
MC

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
34
35
36
37
38
39
40
41
##---- 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 (x, y, corfun = wincor, alpha = 0.05, nboot = 500, SEED = TRUE, 
    MC = FALSE) 
{
    m1 = cbind(x, y)
    m1 <- elimna(m1)
    nval = nrow(m1)
    x <- m1[, 1:2]
    y = m1[, 3]
    est <- cor2xy(x, y, corfun = corfun)$cor
    r12 = est[1]
    r13 = est[2]
    if (SEED) 
        set.seed(2)
    data <- matrix(sample(length(y), size = length(y) * nboot, 
        replace = TRUE), nrow = nboot)
    data = listm(t(data))
    if (MC) {
        library(parallel)
        bvec <- mclapply(data, twoDcorR_sub, x, y, corfun)
    }
    if (!MC) 
        bvec <- lapply(data, twoDcorR_sub, x, y, corfun)
    mat = matrix(NA, nrow = nboot, ncol = 2)
    for (i in 1:nboot) mat[i, ] = bvec[[i]]
    ihi <- floor((1 - alpha/2) * nboot + 0.5)
    ilow <- floor((alpha/2) * nboot + 0.5)
    corhat = cor(mat^2)[1, 2]
    bsort <- sort(mat[, 1] - mat[, 2])
    ci12 <- 1
    ci12[1] <- bsort[ilow]
    ci12[2] <- bsort[ihi]
    pv = mean(bsort < 0)
    pv = 2 * min(c(pv, 1 - pv))
    list(est.rho1 = r12, est.rho2 = r13, est.dif = r12 - r13, 
        ci = ci12, p.value = pv)
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.