View source: R/bin_multitest.R
1 | bin_multitest(i, k, variable, select, testdata, testlevel, levs, position0, position1, method, psigalpha = 0.05)
|
i |
|
k |
|
variable |
|
select |
|
testdata |
|
testlevel |
|
levs |
|
position0 |
|
position1 |
|
method |
|
psigalpha |
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 | ##---- 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 (i, k, variable, select, testdata, testlevel, levs,
position0, position1, method, psigalpha = 0.05)
{
group <- testdata[[variable]]
n1 <- length(position0)
n2 <- length(position1)
group[sample(position0, k)] <- levs[2]
group[sample(position1, k)] <- levs[1]
group <- factor(group)
if (method == "kruskal") {
otu.test <- apply(testlevel, 2, function(x) {
kt <- kruskal.test(x = x, g = group)
return(data.frame(pv = kt$p.value, es = kt$statistic/sqrt(n1^2 +
n2^2)))
})
otu.test <- do.call(rbind, otu.test)
}
else if (method == "wilcox") {
otu.test <- apply(testlevel, 2, function(x) {
wt <- wilcox.test(x ~ group)
return(data.frame(pv = wt$p.value, es = wt$statistic/sqrt(n1^2 +
n2^2)))
})
otu.test <- do.call(rbind, otu.test)
}
psig <- sum(!otu.test$pv > psigalpha, na.rm = T)
pvalue <- -log10(otu.test$pv[select])
effectsize <- otu.test$es
effectsize <- effectsize[select]
return(list(psig = psig, pvalue = pvalue, effectsize = effectsize))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.