regmed2:

Usage Arguments Examples

Usage

1
regmed2(x, y, regfun = tsreg, nboot = 400, alpha = 0.05, xout = FALSE, outfun = out, MC = FALSE, SEED = TRUE, pr = TRUE, ...)

Arguments

x
y
regfun
nboot
alpha
xout
outfun
MC
SEED
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
##---- 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 = 400, alpha = 0.05, xout = FALSE, 
    outfun = out, MC = FALSE, SEED = TRUE, pr = TRUE, ...) 
{
    if (MC) 
        library(parallel)
    x <- as.matrix(x)
    p1 <- ncol(x) + 1
    p <- ncol(x)
    if (p != 2) 
        stop("Argument x should have two columns")
    xy <- cbind(x, y)
    xy <- elimna(xy)
    x <- xy[, 1:p]
    y <- xy[, p1]
    if (xout) {
        m <- cbind(x, y)
        flag <- outfun(x, plotit = FALSE)$keep
        m <- m[flag, ]
        x <- m[, 1:p]
        y <- m[, p1]
    }
    if (MC) {
        temp1 = regciMC(x[, 1], x[, 2], regfun = regfun, nboot = nboot, 
            alpha = alpha, SEED = SEED, pr = FALSE)
        temp2 = regciMC(x, y, regfun = regfun, nboot = nboot, 
            alpha = alpha, SEED = SEED, pr = FALSE)
    }
    if (!MC) {
        temp1 = regci(x[, 1], x[, 2], regfun = regfun, nboot = nboot, 
            alpha = alpha, SEED = SEED, pr = FALSE)
        temp2 = regci(x, y, regfun = regfun, nboot = nboot, alpha = alpha, 
            SEED = SEED, pr = FALSE)
    }
    if (pr) {
        print("Output returned in res1 is for the slope of the regression line")
        print("where the goal is to predict the mediator variable given the other")
        print("predictor variable stored in column 1 of x.")
        print("Output in res2 is for slope of the mediator when both predictors are used.")
    }
    res1 = c(temp1$regci[2, ], temp1$p.value[2])
    z1 = t(as.matrix(res1))
    dimnames(z1) = list(NULL, c("ci.low", "ci.up", "Estimate", 
        "S.E.", "p.value"))
    res2 = c(temp2$regci[3, ], temp2$p.value[3])
    z2 = t(as.matrix(res2))
    dimnames(z2) = list(NULL, c("ci.low", "ci.up", "Estimate", 
        "S.E.", "p.value"))
    list(res1 = z1, res2 = z2)
  }

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