binband:

Usage Arguments Examples

Usage

1
binband(x, y, KMS = FALSE, alpha = 0.05, ADJ.P = FALSE)

Arguments

x
y
KMS
alpha
ADJ.P

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
##---- 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, KMS = FALSE, alpha = 0.05, ADJ.P = FALSE) 
{
    x = elimna(x)
    y = elimna(y)
    vals = sort(unique(c(x, y)))
    ncon = length(vals)
    n1 = length(x)
    n2 = length(y)
    p.values = NA
    adj = 1
    cv = 1
    if (!KMS) {
        output = matrix(NA, ncol = 6, nrow = length(vals))
        dimnames(output) = list(NULL, c("Value", "p1.est", "p2.est", 
            "p1-p2", "p.value", "p.crit"))
    }
    if (KMS) {
        output = matrix(NA, ncol = 8, nrow = length(vals))
        dimnames(output) = list(NULL, c("Value", "p1.est", "p2.est", 
            "p1-p2", "ci.low", "ci.up", "p.value", "p.crit"))
    }
    for (i in 1:length(vals)) {
        x1 = sum(x == vals[i])
        y1 = sum(y == vals[i])
        if (!KMS) {
            output[i, 5] = twobinom(x1, n1, y1, n2)$p.value
            output[i, 2] = x1/n1
            output[i, 3] = y1/n2
            output[i, 1] = vals[i]
            output[i, 4] = output[i, 2] - output[i, 3]
        }
        if (KMS) {
            temp = bi2KMSv2(x1, n1, y1, n2)
            output[i, 1] = vals[i]
            output[i, 5] = temp$ci[1]
            output[i, 6] = temp$ci[2]
            output[i, 2] = x1/n1
            output[i, 3] = y1/n2
            output[i, 4] = output[i, 2] - output[i, 3]
            output[i, 7] = temp$p.value
        }
    }
    ncon = length(vals)
    dvec = alpha/c(1:ncon)
    if (ADJ.P) {
        mn = max(c(n1, n2))
        cv = 1
        if (ncon != 2) {
            if (mn > 50) {
                cv = 2 - (mn - 50)/50
                if (cv < 1) 
                  cv = 1
            }
            if (mn <= 50) 
                cv = 2
        }
        if (KMS) {
            flag = (output[, 7] <= 2 * alpha)
            output[flag, 8] = output[flag, 8]/cv
        }
        if (!KMS) {
            cv = 1
            flag = (output[, 5] <= 2 * alpha)
            if (min(c(n1, n2)) < 20 && n1 != n2 && ncon >= 5) 
                cv = 2
            output[flag, 5] = output[flag, 5]/cv
        }
    }
    if (KMS) {
        temp2 = order(0 - output[, 7])
        output[temp2, 8] = dvec
    }
    if (!KMS) {
        temp2 = order(0 - output[, 5])
        output[temp2, 6] = dvec
    }
    output
  }

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