trimpb2:

Usage Arguments Examples

Usage

1
trimpb2(x, y, tr = 0.2, alpha = 0.05, nboot = 2000, WIN = FALSE, win = 0.1, plotit = FALSE, op = 4, SEED = TRUE)

Arguments

x
y
tr
alpha
nboot
WIN
win
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
##---- 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 = 2000, WIN = FALSE, 
    win = 0.1, plotit = FALSE, op = 4, SEED = TRUE) 
{
    x <- x[!is.na(x)]
    y <- y[!is.na(y)]
    if (WIN) {
        if (win > tr) 
            stop("Cannot Winsorize more than you trim")
        if (tr < 0.2) {
            print("When Winsorizing, the amount of trimming")
            print("should be at least .2")
        }
        if (min(c(length(x), length(y))) < 15) {
            print("Warning: Winsorizing with sample sizes less than 15")
            print("can result in poor control over the probability of a Type I error")
        }
        x <- winval(x, win)
        y <- winval(y, win)
    }
    xx <- list()
    xx[[1]] <- x
    xx[[2]] <- y
    est.dif <- tmean(xx[[1]], tr = tr) - tmean(xx[[2]], tr = tr)
    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, mean, tr)
    }
    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]
    if (plotit) 
        g2plot(bvec[1, ], bvec[2, ], op = op)
    list(p.value = 2 * test, ci = ci, est.dif = est.dif)
  }

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