DregGMC:

Usage Arguments Examples

Usage

1
DregGMC(x1, y1, x2, y2, nullv = NULL, regfun = tsreg, nboot = 500, xout = FALSE, outfun = outpro, SEED = TRUE, plotit = FALSE, pr = TRUE, ...)

Arguments

x1
y1
x2
y2
nullv
regfun
nboot
xout
outfun
SEED
plotit
pr
...

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
59
60
61
62
63
64
65
66
67
68
69
70
71
##---- 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 (x1, y1, x2, y2, nullv = NULL, regfun = tsreg, nboot = 500, 
    xout = FALSE, outfun = outpro, SEED = TRUE, plotit = FALSE, 
    pr = TRUE, ...) 
{
    flag = FALSE
    library(parallel)
    if (SEED) 
        set.seed(2)
    X = elimna(cbind(x1, y1, x2, y2))
    x1 = as.matrix(x1)
    x2 = as.matrix(x2)
    p = ncol(x1)
    p1 = p + 1
    p2 = p + 2
    p3 = p1 + p
    p4 = p3 + 1
    if (is.null(nullv)) 
        nullv = rep(0, p1)
    x1 = X[, 1:p]
    y1 = X[, p1]
    x2 = X[, p2:p3]
    y2 = X[, p4]
    n = length(y1)
    if (xout) {
        flag1 = outfun(x1, ...)$out.id
        flag2 = outfun(x2, ...)$out.id
        flag = unique(c(flag1, flag2))
        if (length(flag) > 0) 
            X = X[-flag, ]
        x1 = X[, 1:p]
        y1 = X[, p1]
        x2 = X[, p2:p3]
        y2 = X[, p4]
    }
    flagF = FALSE
    flagF = identical(regfun, tsreg)
    if (flagF) {
        if (pr) {
            if (sum(duplicated(y1) > 0)) 
                print("Duplicate values detected; regfun=tshdreg might have more power than tsreg")
            pr = FALSE
        }
        if (pr) {
            if (sum(duplicated(y2) > 0)) 
                print("Duplicate values detected; regfun=tshdreg might have more power than tsreg")
        }
    }
    x1 = as.matrix(x1)
    x2 = as.matrix(x2)
    data <- matrix(sample(length(y1), size = length(y1) * nboot, 
        replace = TRUE), nrow = nboot)
    data = listm(t(data))
    bvec1 = mclapply(data, regbootMC, x1, y1, regfun, xout = FALSE, 
        ...)
    bvec1 = matl(bvec1)
    bvec2 = mclapply(data, regbootMC, x2, y2, regfun, xout = FALSE, 
        ...)
    bvec2 = matl(bvec2)
    dif = t(bvec1 - bvec2)
    temp <- pdisMC(rbind(dif, nullv))
    sig.level <- sum(temp[nboot + 1] < temp[1:nboot])/nboot
    est1 = regfun(x1, y1)$coef
    est2 = regfun(x2, y2)$coef
    est = est1 - est2
    list(p.value = sig.level, est.1 = est1, est.2 = est2, estimate.dif = est)
  }

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