multistage: some title

Usage Arguments Examples

View source: R/multistage.R

Usage

1
multistage(pValues, alpha = 0.05)

Arguments

pValues
alpha

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
##---- 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 (pValues, alpha = 0.05) 
{
    result <- list()
    k <- length(pValues)
    flpvalues <- numeric()
    for (i in 1:k) {
        fpValues <- pValues[[i]]
        sortfpValues <- sort(fpValues)
        fm <- length(fpValues)
        conjpValues <- numeric()
        for (i in 1:fm) {
            locpvalue <- (sortfpValues[[i]] * fm/i)
            conjpValues <- c(conjpValues, locpvalue)
        }
        flpvalues <- c(flpvalues, min(conjpValues))
    }
    ktilde <- c(1, 1)
    R <- c(k, k)
    famlevel <- BH(flpvalues, alpha = alpha, silent = TRUE)$rejected
    R[[2]] <- length(famlevel[famlevel == TRUE])
    x <- 0
    if (famlevel[[1]] == FALSE && famlevel[[2]] == FALSE) {
        x <- 1
    }
    u <- 0
    while (x == 0) {
        u <- u + 1
        if (famlevel[[1]] == TRUE) {
            fpValues <- pValues[[1]]
            sortfpValues <- sort(fpValues)
            fm <- length(fpValues)
            fu <- min(c(fm, u))
            conjpValues <- numeric()
            for (i in 1:(fm - fu + 1)) {
                locpvalue <- (sortfpValues[[(fu - 1 + i)]] * 
                  (fm - fu + 1)/i)
                conjpValues <- c(conjpValues, locpvalue)
            }
            flpvalues[[1]] <- min(conjpValues)
            ktilde[[1]] <- u
        }
        if (famlevel[[1]] == FALSE) {
            flpvalues[[1]] <- 1
        }
        if (famlevel[[2]] == TRUE) {
            fpValues <- pValues[[2]]
            sortfpValues <- sort(fpValues)
            fm <- length(fpValues)
            fu <- min(c(fm, u))
            conjpValues <- numeric()
            for (i in 1:(fm - fu + 1)) {
                locpvalue <- (sortfpValues[[(fu - 1 + i)]] * 
                  (fm - fu + 1)/i)
                conjpValues <- c(conjpValues, locpvalue)
            }
            flpvalues[[2]] <- min(conjpValues)
            ktilde[[2]] <- u
        }
        if (famlevel[[2]] == FALSE) {
            flpvalues[[2]] <- 1
        }
        famlevel <- BH(flpvalues, alpha = alpha * (R[[2]]/R[[1]]), 
            silent = TRUE)$rejected
        R[[1]] <- R[[2]]
        R[[2]] <- length(famlevel[famlevel == TRUE])
        if (famlevel[[1]] == FALSE && famlevel[[2]] == FALSE) {
            x <- 1
        }
        if (u == max(length(pValues[[1]]), length(pValues[[2]]))) {
            x <- 1
        }
    }
    gone <- sort(pValues[[1]])
    ktildo <- ktilde[[1]]
    grenzone <- gone[[ktildo]]
    rejfamone <- (pValues[[1]] <= grenzone)
    gtwo <- sort(pValues[[2]])
    ktildtwo <- ktilde[[2]]
    grenztwo <- gtwo[[ktildtwo]]
    rejfamtwo <- (pValues[[2]] <= grenztwo)
    result <- c(list(rejfamone), list(rejfamtwo))
    return(result)
  }

WIAS-BERLIN/hierarchicalFDR documentation built on Dec. 30, 2019, 11:49 p.m.