twoKlin:

Usage Arguments Examples

Usage

1
twoKlin(x = NULL, x1 = NULL, x2 = NULL, tr = 0.2, alpha = 0.05, pr = TRUE, opt = 1)

Arguments

x
x1
x2
tr
alpha
pr
opt

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
##---- 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 = NULL, x1 = NULL, x2 = NULL, tr = 0.2, alpha = 0.05, 
    pr = TRUE, opt = 1) 
{
    if (is.null(x[1])) {
        if (is.matrix(x1)) 
            x = cbind(x1, x2)
        if (is.list(x1)) 
            x = c(x1, x2)
    }
    if (is.matrix(x)) 
        x = listm(x)
    crit = NA
    n1 = NA
    n2 = NA
    if (is.matrix(x) || is.data.frame(x)) 
        K2 = ncol(x)
    if (is.list(x)) 
        K2 = length(x)
    K = floor(K2/2)
    if (2 * K != K2) 
        stop("Total number of groups, K2, should be an even number")
    ic = 0
    ic2 = K
    pv = NULL
    for (i in 1:K) {
        ic = ic + 1
        ic2 = ic2 + 1
        testit = yuen(x[[ic]], x[[ic2]], tr = tr, alpha = alpha)
        n1[ic] = testit$n1
        n2[ic] = testit$n2
        pv[ic] = testit$p.value
    }
    pick = NULL
    v = order(pv)
    ic = 0
    for (i in K:1) {
        K2 = 2 * K
        flag = TRUE
        if (opt == 1) {
            i2 = i * 2
            if (i == K) 
                res = (0 - 2) * sum(log(pv))
            if (i < K) 
                res = (0 - 2) * sum(log(pv[-pick]))
            pvF = 1 - pchisq(res, i2)
        }
        if (opt == 2) {
            if (i == K) 
                res = sum(qnorm(pv/2)^2)
            if (i < K) 
                res = sum(qnorm(pv[-pick]/2)^2)
            pvF = 1 - pchisq(res, i)
        }
        if (opt == 3) {
            if (i == K) 
                res = max(pv)
            if (i < K) 
                res = max(pv[-pick])
            pvF = pbeta(res, i, 1)
        }
        if (pvF > alpha) 
            flag = TRUE
        if (pvF <= alpha/(K + 1 - i)) {
            ic = ic + 1
            pick = c(pick, v[ic])
            flag = FALSE
            if (pv[v[ic]] > alpha) 
                flag = TRUE
        }
        if (flag) 
            break
    }
    Decision = rep("Not Sig", length(pv))
    if (!is.null(pick)) 
        Decision[pick] = "Reject"
    nsig = sum(length(pick))
    list(n1 = n1, n2 = n2, p.values = pv, Decisions = as.matrix(Decision), 
        num.sig = nsig)
  }

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