Description Usage Arguments Details Value See Also
nestedRanksTest_Z is used by nestedRanksTest to
calculate the Z-score for the ranks of responses y divided
into two treatment levels.
1 | nestedRanksTest_Z(y, n1, n2)
|
y |
Values to be ranked for the test. Its length must
be equal to the sum of |
n1 |
The first |
n2 |
The final |
Values across both treatments are ranked using the base R function
rank with ties.method = "average", which assigns
tied values their average rank. The Mann-Whitney-Wilcoxon test
statistic is computed from these ranks. Because the value of the
statistic is sample-size dependent (between -n1*n2 and
n1*n2), it is scaled to be [-1,+1] by dividing by
n1*n2.
The bottleneck for bootstrapping is calculation of ranks, so the most
straightforward way to speed up nestedRanksTest would come from
speeding up rank. Because of the checks performed prior to
calling this routine, it should be sufficient to use a stripped-down
function that simply does the equivalent of making an .Internal
call, which is not allowed within package code. As of this writing, this
is sufficient:
rank_new <- function (x) .Internal(rank(x, length(x), "average"))
For the example data this is 8-9 times faster than the base R rank,
because it avoids error-checking overhead. For longer vectors, the
advantage decreases such that at 10000 elements it is 20-30%.
The calculated Z-score
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.