Description Usage Arguments Value Note References See Also Examples
The statistic for the nested ranks test is a Zscore calculated by
comparing ranks between treatment levels, with contributions of each group
to the final Zscore weighted by group size. The pvalue is determined by
comparing the observed Zscore against a distribution of Zscores
calculated by bootstrapping ranks assuming no influence of treatment while
respecting group sizes. When there is just one group, this test is
essentially identical to a standard MannWhitneyWilcoxon test. This test
is intended to be a mixedmodel extension of the wilcox.test
,
for which treatment is a fixed effect and group membership is a random
effect.
1 2 3 4 5 6  ## S3 method for class 'formula'
nestedRanksTest(formula, data, groups = NULL, subset, ...)
## Default S3 method:
nestedRanksTest(x, y, groups, n.iter = 10000,
lightweight = FALSE, ...)

formula 
A formula of the form 
data 
An optional matrix or data frame (or similar: see

groups 
A (nonempty) vector specifying group membership for each

subset 
An optional vector specifying a subset of observations to be used. 
... 
Further arguments to be passed to or from methods. 
x 
A (nonempty) vector of treatments for each 
y 
A (nonempty) numeric vector of data values. 
n.iter 
Number of bootstrap iterations to perform. The value of
the final iteration is provided by the observed Zscore.
Using 
lightweight 
If 
A list with class 'htest_boot'
based on class
'htest'
containing the following components. Components
marked with "*"
are additions to 'htest'
.
statistic  the value of the observed Zscore. 
p.value  the pvalue for the test. 
alternative  a character string describing the alternative hypothesis. 
method  a character string indicating the nested ranks test performed. 
data.name  a character string giving the name(s) of the data. 
bad.obs  the number of observations in the data
excluded because of NA values. 
null.values  quantiles of the null distribution used for calculating the pvalue. 
n.iter*  the number of bootstrap iterations used for generating the null distribution. 
weights*  the weights for groups, calculated by
nestedRanksTest_weights . 
null.distribution*  null distribution of Zscores, with
statistic the last value. 
The length of null.distribution
equals n.iter
. Note that
null.distribution
will not be present if the
lightweight = TRUE
option was given to nestedRanksTest
.
Cases for which any of x
, y
or groups
are
NA
are removed.
The generation of a null distribution can take some time. For
example, if any use of nestedRanksTest
in the examples were
run with the default n.iter = 10000
, completion would require
a few seconds.
Thompson, P. G., Smouse, P. E., Scofield, D. G. and Sork, V. L. (2014) What seeds tell us about birds: a multiyear analysis of acorn woodpecker foraging movements. Movement Ecology 2:12. http://www.movementecologyjournal.com/content/2/1/12
https://github.com/douglasgscofield/nestedRanksTest
wilcox.test
, print.htest_boot
,
plot.htest_boot
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  require(graphics)
data(woodpecker_multiyear)
## S3 method for class 'formula'
## n.iter set to 1000 to shorten completion time
## group in formula
nestedRanksTest(Distance ~ Year  Granary, n.iter = 1000,
data = woodpecker_multiyear,
subset = Species == "agrifolia")
## group in 'groups='
nestedRanksTest(Distance ~ Year, groups = Granary, n.iter = 1000,
data = woodpecker_multiyear,
subset = Species == "lobata")
## Default S3 method
dat.a < subset(woodpecker_multiyear, Species == "agrifolia")
## arguments in default order
nestedRanksTest(dat.a$Year, dat.a$Distance, dat.a$Granary, n.iter = 1000)
## named arguments used in 'formula' order
res < with(subset(woodpecker_multiyear, Species == "lobata"),
nestedRanksTest(y = Distance, x = Year, groups = Granary,
n.iter = 1000))
plot(res)

Nested Ranks Test
data: Distance by Year grouped by Granary
Z = 0.27695, pvalue = 0.001
alternative hypothesis: Z lies above bootstrapped null values
null values:
0% 1% 5% 10% 25% 50% 75% 90% 95% 99%
0.2042 0.1561 0.1129 0.0861 0.0440 0.0045 0.0490 0.0967 0.1211 0.1611
100%
0.2770
bootstrap iterations: 1000
group weights:
10 31 140 151 152 938 942
0.05204461 0.04646840 0.02478315 0.14560099 0.30359356 0.29120198 0.13630731
Nested Ranks Test
data: Distance by Year grouped by Granary
Z = 0.080882, pvalue = 0.064
alternative hypothesis: Z lies above bootstrapped null values
null values:
0% 1% 5% 10% 25% 50% 75% 90% 95% 99%
0.1610 0.1206 0.0847 0.0669 0.0382 0.0022 0.0309 0.0632 0.0854 0.1191
100%
0.1574
bootstrap iterations: 1000
group weights:
9 10 33 39 48 107 163
0.09705882 0.26250000 0.09926471 0.14411765 0.01985294 0.08235294 0.08823529
532 912
0.07279412 0.13382353
Nested Ranks Test
data: dat.a$Distance by dat.a$Year grouped by dat.a$Granary
Z = 0.27695, pvalue = 0.001
alternative hypothesis: Z lies above bootstrapped null values
null values:
0% 1% 5% 10% 25% 50% 75% 90% 95% 99%
0.2224 0.1655 0.1109 0.0875 0.0454 0.0011 0.0534 0.0939 0.1187 0.1552
100%
0.2770
bootstrap iterations: 1000
group weights:
10 31 140 151 152 938 942
0.05204461 0.04646840 0.02478315 0.14560099 0.30359356 0.29120198 0.13630731
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.