ancGLOB:

Usage Arguments Examples

Usage

1
ancGLOB(x1, y1, x2, y2, xout = FALSE, outfun = outpro, est = tmean, p.crit = NULL, nreps = 500, alpha = 0.05, pr = TRUE, nboot = 500, SEED = TRUE, MC = FALSE, CR = FALSE, nmin = 12, pts = NULL, fr1 = 1, fr2 = 1, plotit = TRUE, SCAT = TRUE, pch1 = "+", pch2 = "o", xlab = "X", ylab = "Y", LP = TRUE, cpp = FALSE, ...)

Arguments

x1
y1
x2
y2
xout
outfun
est
p.crit
nreps
alpha
pr
nboot
SEED
MC
CR
nmin
pts
fr1
fr2
plotit
SCAT
pch1
pch2
xlab
ylab
LP
cpp
...

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
116
117
118
119
120
121
122
123
##---- 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, xout = FALSE, outfun = outpro, est = tmean, 
    p.crit = NULL, nreps = 500, alpha = 0.05, pr = TRUE, nboot = 500, 
    SEED = TRUE, MC = FALSE, CR = FALSE, nmin = 12, pts = NULL, 
    fr1 = 1, fr2 = 1, plotit = TRUE, SCAT = TRUE, pch1 = "+", 
    pch2 = "o", xlab = "X", ylab = "Y", LP = TRUE, cpp = FALSE, 
    ...) 
{
    if (CR) 
        plotit = FALSE
    if (SEED) 
        set.seed(2)
    iter = nreps
    pts.flag = is.null(pts)
    if (!is.null(pts)) 
        cpp = FALSE
    x1 <- as.matrix(x1)
    p1 <- ncol(x1) + 1
    p <- ncol(x1)
    if (p > 1) 
        stop("Current version is for one independent variable only")
    xy <- cbind(x1, y1)
    xy <- elimna(xy)
    x1 <- xy[, 1:p]
    y1 <- xy[, p1]
    xy <- cbind(x2, y2)
    xy <- elimna(xy)
    x2 <- xy[, 1:p]
    y2 <- xy[, p1]
    if (xout) {
        m <- cbind(x1, y1)
        flag <- outfun(x1, plotit = FALSE, ...)$keep
        m <- m[flag, ]
        x1 <- m[, 1:p]
        y1 <- m[, p1]
        m <- cbind(x2, y2)
        flag <- outfun(x2, plotit = FALSE, ...)$keep
        m <- m[flag, ]
        x2 <- m[, 1:p]
        y2 <- m[, p1]
    }
    N1 = length(y1)
    N2 = length(y2)
    if (is.null(pts[1])) {
        isub <- c(1:5)
        test <- c(1:5)
        xorder <- order(x1)
        y1 <- y1[xorder]
        x1 <- x1[xorder]
        xorder <- order(x2)
        y2 <- y2[xorder]
        x2 <- x2[xorder]
        n1 <- 1
        n2 <- 1
        vecn <- 1
        for (i in 1:length(x1)) n1[i] <- length(y1[near(x1, x1[i], 
            fr1)])
        for (i in 1:length(x1)) n2[i] <- length(y2[near(x2, x1[i], 
            fr2)])
        for (i in 1:length(x1)) vecn[i] <- min(n1[i], n2[i])
        sub <- c(1:length(x1))
        isub[1] <- min(sub[vecn >= nmin])
        isub[5] <- max(sub[vecn >= nmin])
        isub[3] <- floor((isub[1] + isub[5])/2)
        isub[2] <- floor((isub[1] + isub[3])/2)
        isub[4] <- floor((isub[3] + isub[5])/2)
        pts = x1[isub]
        g1 = list()
        g2 = list()
        for (i in 1:5) {
            g1[[i]] <- y1[near(x1, x1[isub[i]], fr1)]
            g2[[i]] <- y2[near(x2, x1[isub[i]], fr2)]
        }
    }
    if (!is.null(pts[1])) {
        if (length(pts) < 2) 
            stop("Should have at least two points (use the R function ancova)")
        g1 = list()
        g2 = list()
        for (i in 1:length(pts)) {
            g1[[i]] <- y1[near(x1, pts[i], fr1)]
            g2[[i]] <- y2[near(x2, pts[i], fr2)]
        }
    }
    p.alpha = NULL
    if (is.null(p.crit)) {
        if (pts.flag) {
            if (cpp) {
                library(WRScpp)
                ve = ancGLOB_pv_C(N1, N2, est = est, iter = iter, 
                  fr1 = fr1, fr2 = fr2, nboot = nboot, SEED = SEED, 
                  ...)
                v = hd(ve, q = alpha)
            }
            else {
                v = ancGLOB_pv(N1, N2, est = est, iter = iter, 
                  fr1 = fr1, fr2 = fr2, nboot = nboot, PRM = FALSE, 
                  SEED = SEED, alpha = alpha, xlab = xlab, ylab = ylab, 
                  ...)$p.crit
            }
        }
        if (!pts.flag) 
            v = ancGLOB_pv_pts(x1, x2, pts = pts, nmin = nmin, 
                iter = iter, est = est, fr1 = fr1, fr2 = fr2, 
                nboot = nboot, SEED = SEED, alpha = alpha, MC = MC)$p.crit
    }
    if (!is.null(p.crit)) 
        v = p.crit
    res = aov2depth(g1, g2, est = est, SEED = SEED, CR = CR, 
        alpha = v, ...)
    if (pr) 
        print("Reject if p.test is less than p.crit")
    if (plotit) 
        runmean2g(x1, y1, x2, y2, fr = fr1, est = est, xout = FALSE, 
            LP = LP, xlab = xlab, ylab = ylab, SCAT = SCAT, pch1 = pch1, 
            pch2 = pch2, ...)
    list(p.test = res$p.value, p.crit = v, est1 = res$est1, est2 = res$est2, 
        dif = res$dif, pts = pts, n1 = res$n1, n2 = res$n2)
  }

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