Description Usage Arguments Details Value Author(s) Examples
View source: R/phylogeneticUtilities.R
compares means by bootstrap resampling of differences between empirical distributions
1 | resamp.test(obs = obs, exp = exp, mu = 0, iter = 10000, two.tailed = FALSE, na.rm = TRUE)
|
obs |
a vector of numeric values |
exp |
a vector of numeric values |
mu |
the true difference in means |
iter |
number of randomization comparisons to perform |
two.tailed |
Boolean; as default, the test is performed under a one-tailed assumption |
na.rm |
whether to remove NA data |
If a single value is supplied for obs
, this test equates to finding the quantile in exp
in which obs
would be found (under a one-tailed test);
see Examples and also ecdf
A list, whose contents are determined by the above argument:
unnamed value |
if |
diffs |
the full resampling distribution of differences between |
greater |
if |
lesser |
if |
Jonathan Eastman
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 | ## A GENERAL EXAMPLE
# a comparison between two distributions
a=rnorm(n=1000, mean=1, sd=0.5)
b=rnorm(n=1000, mean=0, sd=1)
resamp.test(obs=a, exp=b, two.tailed=FALSE)
# a comparison of a single value to a normal distribution
a=3
b=rnorm(n=1000, mean=0, sd=1)
resamp.test(obs=a, exp=b, two.tailed=FALSE)
# compare above result with ecdf(), in which we compute an empirical
f=ecdf(b)
print(1-f(a)) # analogous to a one-tailed test as above
## A COMMUNITY PHYLOGENETIC EXAMPLE
## an example of comparing observed and expected Bst at nodes ##
data(sp.example)
attach(sp.example)
s=spl
p=phy
# get nodes for a time-slice
n.t=phy.nodetimes(phy=p,time.range=c(0.25, 0.75))
# get Bsts for nodes
o=spacodi.by.nodes(sp.plot=s, phy=p, obs.only=TRUE)[[1]]
obs=o[!is.na(match(o[,"node.ID"], names(n.t))),1]
# compile expected Bst-values from data reshuffling
spacodi.by.nodes(sp.plot=s, phy=p, n.rep=5, method="1s")[[2]]->exps
e=exps[!is.na(match(row.names(exps), names(n.t))),]
exp=unname(unlist(e))
# randomization test of observed and expected Bst
resamp.test(obs=obs, exp=exp, iter=100, two.tailed=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.