yuenbt:

Usage Arguments Examples

Usage

1
yuenbt(x, y, tr = 0.2, alpha = 0.05, nboot = 599, side = TRUE, nullval = 0, pr = TRUE, plotit = FALSE, op = 1, SEED = TRUE)

Arguments

x
y
tr
alpha
nboot
side
nullval
pr
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
56
57
58
##---- 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, 
    nullval = 0, pr = TRUE, plotit = FALSE, op = 1, SEED = TRUE) 
{
    side <- as.logical(side)
    p.value <- NA
    yuenbt <- vector(mode = "numeric", length = 2)
    if (SEED) 
        set.seed(2)
    x <- x[!is.na(x)]
    y <- y[!is.na(y)]
    xcen <- x - mean(x, tr)
    ycen <- y - mean(y, tr)
    if (!side) {
        if (pr) 
            print("NOTE: p-value computed only when side=T")
    }
    test <- (mean(x, tr) - mean(y, tr))/sqrt(trimse(x, tr = tr)^2 + 
        trimse(y, tr = tr)^2)
    datax <- matrix(sample(xcen, size = length(x) * nboot, replace = TRUE), 
        nrow = nboot)
    datay <- matrix(sample(ycen, size = length(y) * nboot, replace = TRUE), 
        nrow = nboot)
    top <- apply(datax, 1, mean, tr) - apply(datay, 1, mean, 
        tr)
    botx <- apply(datax, 1, trimse, tr)
    boty <- apply(datay, 1, trimse, tr)
    tval <- top/sqrt(botx^2 + boty^2)
    if (plotit) {
        if (op == 1) 
            akerd(tval)
        if (op == 2) 
            rdplot(tval)
    }
    if (side) 
        tval <- abs(tval)
    tval <- sort(tval)
    icrit <- floor((1 - alpha) * nboot + 0.5)
    ibot <- floor(alpha * nboot/2 + 0.5)
    itop <- floor((1 - alpha/2) * nboot + 0.5)
    se <- sqrt((trimse(x, tr))^2 + (trimse(y, tr))^2)
    yuenbt[1] <- mean(x, tr) - mean(y, tr) - tval[itop] * se
    yuenbt[2] <- mean(x, tr) - mean(y, tr) - tval[ibot] * se
    if (side) {
        yuenbt[1] <- mean(x, tr) - mean(y, tr) - tval[icrit] * 
            se
        yuenbt[2] <- mean(x, tr) - mean(y, tr) + tval[icrit] * 
            se
        p.value <- (sum(abs(test) <= abs(tval)))/nboot
    }
    list(ci = yuenbt, test.stat = test, p.value = p.value, est.1 = mean(x, 
        tr), est.2 = mean(y, tr), est.dif = mean(x, tr) - mean(y, 
        tr), n1 = length(x), n2 = length(y))
  }

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