mulwmwv2:

Usage Arguments Examples

Usage

1
mulwmwv2(m1, m2, plotit = TRUE, cop = 3, alpha = 0.05, nboot = 1000, pop = 4, fr = 0.8, pr = FALSE)

Arguments

m1
m2
plotit
cop
alpha
nboot
pop
fr
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
 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
##---- 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 (m1, m2, plotit = TRUE, cop = 3, alpha = 0.05, nboot = 1000, 
    pop = 4, fr = 0.8, pr = FALSE) 
{
    if (is.null(dim(m1))) {
        print("Data are assumed to be stored in")
        print(" a matrix or data frame having two or more columns.")
        stop(" For univariate data, use the function outbox or out")
    }
    m1 <- elimna(m1)
    m2 <- elimna(m2)
    n1v = nrow(m1)
    n2v = nrow(m2)
    if (cop == 1) {
        if (ncol(m1) > 2) {
            center1 <- dmean(m1, tr = 0.5)
            center2 <- dmean(m2, tr = 0.5)
        }
        if (ncol(m1) == 2) {
            tempd <- NA
            for (i in 1:nrow(m1)) tempd[i] <- depth(m1[i, 1], 
                m1[i, 2], m1)
            mdep <- max(tempd)
            flag <- (tempd == mdep)
            if (sum(flag) == 1) 
                center1 <- m1[flag, ]
            if (sum(flag) > 1) 
                center1 <- apply(m1[flag, ], 2, mean)
            for (i in 1:nrow(m2)) tempd[i] <- depth(m2[i, 1], 
                m2[i, 2], m2)
            mdep <- max(tempd)
            flag <- (tempd == mdep)
            if (sum(flag) == 1) 
                center2 <- m2[flag, ]
            if (sum(flag) > 1) 
                center2 <- apply(m2[flag, ], 2, mean)
        }
    }
    if (cop == 2) {
        center1 <- cov.mcd(m1)$center
        center2 <- cov.mcd(m2)$center
    }
    if (cop == 3) {
        center1 <- apply(m1, 2, median)
        center2 <- apply(m2, 2, median)
    }
    if (cop == 4) {
        center1 <- smean(m1)
        center2 <- smean(m2)
    }
    center <- (center1 + center2)/2
    B <- center1 - center2
    if (sum(center1^2) < sum(center2^2)) 
        B <- (0 - 1) * B
    BB <- B^2
    bot <- sum(BB)
    disx <- NA
    disy <- NA
    if (bot != 0) {
        for (j in 1:nrow(m1)) {
            AX <- m1[j, ] - center
            tempx <- sum(AX * B) * B/bot
            disx[j] <- sign(sum(AX * B)) * sqrt(sum(tempx^2))
        }
        for (j in 1:nrow(m2)) {
            AY <- m2[j, ] - center
            tempy <- sum(AY * B) * B/bot
            disy[j] <- sign(sum(AY * B)) * sqrt(sum(tempy^2))
        }
    }
    es = yuenv2(disx, disy)$Effect.Size
    if (plotit) {
        if (pop == 1) {
            par(yaxt = "n")
            xv <- rep(2, length(disx))
            yv <- rep(1, length(disy))
            plot(c(disx, disy), c(xv, yv), type = "n", xlab = "", 
                ylab = "")
            xv <- rep(1.6, length(disx))
            yv <- rep(1.4, length(disy))
            points(disx, xv)
            points(disy, yv)
        }
        if (pop == 2) 
            boxplot(disx, disy)
        if (pop == 3) 
            rd2plot(disx, disy, fr = fr)
        if (pop == 4) 
            g2plot(disx, disy, fr = fr)
    }
    m <- outer(disx, disy, FUN = "-")
    m <- sign(m)
    phat <- (1 - mean(m))/2
    if (bot == 0) 
        phat <- 0.5
    print("Computing critical values")
    m1 <- t(t(m1) - center1)
    m2 <- t(t(m2) - center2)
    v1 <- mulwmwcrit(m1, m2, cop = cop, alpha = alpha, iter = nboot, 
        pr = pr)
    list(phat = phat, lower.crit = v1[1], upper.crit = v1[2], 
        Effect.Size = abs(es), n1 = n1v, n2 = n2v)
  }

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