medpb2:

Usage Arguments Examples

Usage

1
medpb2(x, y = NULL, alpha = 0.05, nboot = 2000, SEED = TRUE)

Arguments

x
y
alpha
nboot
SEED

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
42
43
44
45
46
47
48
49
50
##---- 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 = NULL, alpha = 0.05, nboot = 2000, SEED = TRUE) 
{
    if (is.null(y)) {
        if (is.matrix(x) || is.data.frame(x)) {
            y = x[, 2]
            x = x[, 1]
        }
        if (is.list(x)) {
            y = x[[2]]
            x = x[[1]]
        }
    }
    x = elimna(x)
    y = elimna(y)
    xx <- list()
    xx[[1]] <- x
    xx[[2]] <- y
    if (SEED) 
        set.seed(2)
    est1 = median(xx[[1]])
    est2 = median(xx[[2]])
    est.dif <- median(xx[[1]]) - median(xx[[2]])
    crit <- alpha/2
    temp <- round(crit * nboot)
    icl <- temp + 1
    icu <- nboot - temp
    bvec <- matrix(NA, nrow = 2, ncol = nboot)
    if (SEED) 
        set.seed(2)
    for (j in 1:2) {
        data <- matrix(sample(xx[[j]], size = length(xx[[j]]) * 
            nboot, replace = TRUE), nrow = nboot)
        bvec[j, ] <- apply(data, 1, median)
    }
    top <- bvec[1, ] - bvec[2, ]
    test <- sum(top < 0)/nboot + 0.5 * sum(top == 0)/nboot
    if (test > 0.5) 
        test <- 1 - test
    top <- sort(top)
    ci <- NA
    ci[1] <- top[icl]
    ci[2] <- top[icu]
    list(n1 = length(x), n2 = length(y), p.value = 2 * test, 
        ci = ci, est1 = est1, est2 = est2, est.dif = est.dif)
  }

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