regciMC:

Usage Arguments Examples

Usage

1
regciMC(x, y, regfun = tsreg, nboot = 599, alpha = 0.05, plotit = FALSE, pr = TRUE, xlab = "Predictor 1", ylab = "Predictor 2", xout = FALSE, outfun = outpro, SEED = TRUE, ...)

Arguments

x
y
regfun
nboot
alpha
plotit
pr
xlab
ylab
xout
outfun
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
##---- 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, regfun = tsreg, nboot = 599, alpha = 0.05, plotit = FALSE, 
    pr = TRUE, xlab = "Predictor 1", ylab = "Predictor 2", xout = FALSE, 
    outfun = outpro, SEED = TRUE, ...) 
{
    library(parallel)
    x <- as.matrix(x)
    p1 <- ncol(x) + 1
    p <- ncol(x)
    xy <- cbind(x, y)
    xy <- elimna(xy)
    x <- xy[, 1:p]
    y <- xy[, p1]
    nrem = length(y)
    estit = regfun(x, y, xout = xout, ...)$coef
    if (xout) {
        if (pr) 
            print("Default for argument outfun is now outpro")
        m <- cbind(x, y)
        flag <- outfun(x, plotit = FALSE, ...)$keep
        m <- m[flag, ]
        x <- m[, 1:p]
        y <- m[, p1]
    }
    flagF = identical(regfun, tsreg)
    if (flagF) {
        if (pr) {
            if (sum(duplicated(y) > 0)) 
                print("Duplicate values detected; tshdreg might have more power than tsreg")
        }
    }
    x = as.matrix(x)
    if (SEED) 
        set.seed(2)
    data <- matrix(sample(length(y), size = length(y) * nboot, 
        replace = TRUE), nrow = nboot)
    data = listm(t(data))
    bvec <- mclapply(data, regbootMC, x, y, regfun, mc.preschedule = TRUE, 
        xout = FALSE, ...)
    bvec = matl(bvec)
    p1 <- ncol(x) + 1
    regci <- matrix(0, p1, 5)
    vlabs = "Intercept"
    for (j in 2:p1) vlabs[j] = paste("Slope", j - 1)
    dimnames(regci) <- list(vlabs, c("ci.low", "ci.up", "Estimate", 
        "S.E.", "p-value"))
    ilow <- round((alpha/2) * nboot)
    ihi <- nboot - ilow
    ilow <- ilow + 1
    se <- NA
    sig.level <- NA
    for (i in 1:p1) {
        temp = (sum(bvec[i, ] < 0) + 0.5 * sum(bvec[i, ] == 0))/nboot
        sig.level[i] <- 2 * (min(temp, 1 - temp))
        bsort <- sort(bvec[i, ])
        regci[i, 1] <- bsort[ilow]
        regci[i, 2] <- bsort[ihi]
        se[i] <- sqrt(var(bvec[i, ]))
    }
    if (p1 == 3) {
        if (plotit) {
            plot(bvec[2, ], bvec[3, ], xlab = xlab, ylab = ylab)
        }
    }
    regci[, 3] = estit
    regci[, 4] = se
    regci[, 5] = sig.level
    list(regci = regci, n = nrem, n.keep = length(y))
  }

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