ydbt:

Usage Arguments Examples

Usage

1
ydbt(x, y, tr = 0.2, alpha = 0.05, nboot = 599, side = TRUE, plotit = FALSE, op = 1, SEED = TRUE)

Arguments

x
y
tr
alpha
nboot
side
plotit
op
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
51
52
53
54
55
##---- 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, tr = 0.2, alpha = 0.05, nboot = 599, side = TRUE, 
    plotit = FALSE, op = 1, SEED = TRUE) 
{
    side <- as.logical(side)
    if (length(x) != length(y)) 
        stop("Must have equal sample sizes.")
    m <- cbind(x, y)
    m <- elimna(m)
    x <- m[, 1]
    y <- m[, 2]
    if (sum(c(!is.na(x), !is.na(y))) != (length(x) + length(y))) 
        stop("Missing values are not allowed.")
    if (SEED) 
        set.seed(2)
    print("Taking bootstrap samples. Please wait.")
    data <- matrix(sample(length(y), size = length(y) * nboot, 
        replace = TRUE), nrow = nboot)
    xcen <- x - mean(x, tr)
    ycen <- y - mean(y, tr)
    bvec <- apply(data, 1, tsub, xcen, ycen, tr)
    dotest = yuend(x, y, tr = tr)
    estse <- dotest$se
    p.value = NULL
    dif <- mean(x, tr) - mean(y, tr)
    if (!side) {
        ilow <- round((alpha/2) * nboot)
        ihi <- nboot - ilow
        bsort <- sort(bvec)
        ci <- 0
        ci[1] <- dif - bsort[ihi] * estse
        ci[2] <- dif - bsort[ilow + 1] * estse
    }
    if (side) {
        bsort <- sort(abs(bvec))
        ic <- round((1 - alpha) * nboot)
        ci <- 0
        ci[1] <- dif - bsort[ic] * estse
        ci[2] <- dif + bsort[ic] * estse
        p.value <- (sum(abs(dotest$teststat) <= abs(bvec)))/nboot
    }
    if (plotit) {
        if (op == 1) 
            akerd(bsort)
        if (op == 2) 
            rdplot(bsort)
        if (op == 3) 
            boxplot(bsort)
    }
    list(ci = ci, dif = dif, p.value = p.value)
  }

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