DancovaUB:

Usage Arguments Examples

Usage

1
DancovaUB(x1 = NULL, y1 = NULL, x2 = NULL, y2 = NULL, xy = NULL, fr1 = 1, fr2 = 1, p.crit = NULL, est = tmean, alpha = 0.05, plotit = TRUE, xlab = "X", ylab = "Y", qvals = c(0.25, 0.5, 0.75), sm = FALSE, xout = FALSE, eout = FALSE, outfun = out, DIF = FALSE, LP = TRUE, nboot = 500, SEED = TRUE, nreps = 2000, MC = TRUE, cpp = FALSE, SCAT = TRUE, pch1 = "*", pch2 = "+", nmin = 12, q = 0.5, ...)

Arguments

x1
y1
x2
y2
xy
fr1
fr2
p.crit
est
alpha
plotit
xlab
ylab
qvals
sm
xout
eout
outfun
DIF
LP
nboot
SEED
nreps
MC
cpp
SCAT
pch1
pch2
nmin
q
...

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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
##---- 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 = NULL, y1 = NULL, x2 = NULL, y2 = NULL, xy = NULL, 
    fr1 = 1, fr2 = 1, p.crit = NULL, est = tmean, alpha = 0.05, 
    plotit = TRUE, xlab = "X", ylab = "Y", qvals = c(0.25, 0.5, 
        0.75), sm = FALSE, xout = FALSE, eout = FALSE, outfun = out, 
    DIF = FALSE, LP = TRUE, nboot = 500, SEED = TRUE, nreps = 2000, 
    MC = TRUE, cpp = FALSE, SCAT = TRUE, pch1 = "*", pch2 = "+", 
    nmin = 12, q = 0.5, ...) 
{
    if (SEED) 
        set.seed(2)
    iter = nreps
    if (!is.null(x1[1])) {
        if (ncol(as.matrix(x1)) > 1) 
            stop("One covariate only is allowed with this function")
        if (length(x1) != length(y1)) 
            stop("x1 and y1 have different lengths")
        if (length(x1) != length(x2)) 
            stop("x1 and y2 have different lengths")
        if (length(x2) != length(y2)) 
            stop("x2 and y2 have different lengths")
        if (length(y1) != length(y2)) 
            stop("y1 and y2 have different lengths")
        xy = cbind(x1, y1, x2, y2)
    }
    n = nrow(elimna(xy))
    if (plotit) {
        ef = identical(est, hd)
        if (!ef) 
            runmean2g(xy[, 1], xy[, 2], xy[, 3], xy[, 4], fr = fr1, 
                est = est, sm = sm, xout = xout, LP = LP, eout = eout, 
                xlab = xlab, ylab = ylab, SCAT = SCAT, pch1 = pch1, 
                pch2 = pch2, ...)
        if (ef) 
            runmean2g(xy[, 1], xy[, 2], xy[, 3], xy[, 4], fr = fr1, 
                est = hd, sm = sm, xout = xout, LP = LP, q = q, 
                eout = eout, xlab = xlab, ylab = ylab, SCAT = SCAT, 
                pch1 = pch1, pch2 = pch2, ...)
    }
    if (is.null(p.crit)) {
        if (cpp) 
            library(WRScpp)
        p.crit = DancGLOB_pv(n, fr1 = fr1, fr2 = fr2, nboot = nboot, 
            est = est, SEED = SEED, iter = iter, nmin = nmin, 
            MC = MC, alpha = alpha, qvals = qvals, cpp = cpp)$p.crit
    }
    pts = NULL
    for (i in 1:length(qvals)) pts = c(pts, qest(xy[, 1], qvals[i]))
    if (SEED) 
        set.seed(2)
    ef = identical(est, hd)
    n = nrow(xy)
    est1 = NA
    est2 = NA
    J = length(pts)
    est1 = matrix(NA, nrow = nboot, ncol = J)
    est2 = matrix(NA, nrow = nboot, ncol = J)
    data = matrix(sample(n, size = n * nboot, replace = TRUE), 
        ncol = nboot, nrow = n)
    if (!MC) {
        if (!ef) {
            est1 = apply(data, 2, DancGLOB_sub, xy = xy[, 1:2], 
                pts = pts, est = est, fr = fr1, nmin = nmin, 
                ...)
            est2 = apply(data, 2, DancGLOB_sub, xy = xy[, 3:4], 
                pts = pts, est = est, fr = fr2, nmin = nmin, 
                ...)
        }
        if (ef) {
            est1 = apply(data, 2, DancGLOB_sub, xy = xy[, 1:2], 
                pts = pts, est = hd, fr = fr1, nmin = nmin, q = q, 
                ...)
            est2 = apply(data, 2, DancGLOB_sub, xy = xy[, 3:4], 
                pts = pts, est = hd, fr = fr2, nmin = nmin, q = q, 
                ...)
        }
        est1 = t(as.matrix(est1))
        est2 = t(as.matrix(est2))
    }
    if (MC) {
        library(parallel)
        data = listm(data)
        if (!ef) {
            est1 = mclapply(data, DancGLOB_sub, xy = xy[, 1:2], 
                pts = pts, est = est, fr = fr1, nmin = nmin, 
                ...)
            est2 = mclapply(data, DancGLOB_sub, xy = xy[, 3:4], 
                pts = pts, est = est, fr = fr2, nmin = nmin, 
                ...)
        }
        if (ef) {
            est1 = mclapply(data, DancGLOB_sub, xy = xy[, 1:2], 
                pts = pts, est = hd, fr = fr1, nmin = nmin, q = q, 
                ...)
            est2 = mclapply(data, DancGLOB_sub, xy = xy[, 3:4], 
                pts = pts, est = hd, fr = fr2, nmin = nmin, q = q, 
                ...)
        }
        est1 = t(matl(est1))
        est2 = t(matl(est2))
    }
    pv = NA
    for (j in 1:J) {
        pv[j] = mean(est1[, j] < est2[, j], na.rm = TRUE) + 0.5 * 
            mean(est1[, j] == est2[, j], na.rm = TRUE)
        pv[j] = 2 * min(c(pv[j], 1 - pv[j]))
    }
    pvm = cbind(pts, pv)
    dimnames(pvm) = list(NULL, c("X", "p.values"))
    list(output = pvm, n = n, p.crit = p.crit)
  }

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