Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/TwoStageAdjustment.r
Utility function for the "fdr" function in package mcp.project.
1 | two.stage.adjust(sorted, r = 0, patience = 4)
|
sorted |
~~Describe |
r |
~~Describe |
patience |
~~Describe |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
~~further notes~~
~Make other sections like Warning with Warning .... ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
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 | ##---- 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 (sorted, r = 0, patience = 4)
{
m = length(sorted)
adjusted = rep(0, m)
adjusted.q = solve.q(sorted = sorted, m = m, j = 1, r = 0)
checking = adjusted.q
if (sum(bh(sorted, adjusted.q[1]/(1 + adjusted.q[1]), m = m)$Pvals[["rejected"]]) ==
m) {
adjusted.q = rep(adjusted.q[1], m)
return(adjusted.q)
}
else {
for (j in 1:m) {
delta.r = 1
delta.q = 1
new.q = adjusted.q[j]
r.new = sum(bh(sorted, new.q/(1 + new.q), m = m)$Pvals[["rejected"]])
counter = 0
max.q = 0
while (delta.r > 0 & delta.q > 0) {
old.q = new.q
r.old = r.new
new.q = solve.q(sorted = sorted, m = m, j = j,
r = r.old)[j]
r.new = sum(bh(sorted, new.q/(1 + new.q), m = m)$Pvals[["rejected"]])
delta.r = abs(r.new - r.old)
delta.q = abs(new.q - old.q)
counter = counter + 1
if (counter > patience & max.q != new.q)
max.q = max(max.q, new.q)
else if (counter > patience & max.q == new.q)
break
}
adjusted.q[j] = min(new.q, 1)
adjusted.q[min(j + 1, m)] = adjusted.q[j]
stopifnot(any(adjusted.q[j] <= checking[j]))
}
temp.min = adjusted.q[m]
for (i in m:1) {
if (adjusted.q[i] <= temp.min)
temp.min = adjusted.q[i]
else adjusted.q[i] = temp.min
}
return(adjusted.q)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.