area.diff | R Documentation |
Measure the area difference between two ranked distribution
area.diff(x, y, rarefy, cent.tend = mean, sort = TRUE)
x , y |
the two distributions to compare. |
rarefy |
Optional, if the length of |
cent.tend |
Optional, if the length of |
sort |
|
The number of replicates is chosen based on the variance of the distribution to rarefy using the Silverman's rule of thumb (Silverman 1986, pp.48, eqn 3.31) for choosing the bandwidth of a Gaussian kernel density estimator multiplied by 1000 with a result comprised between 100 and 1000.
For example, for rarefying x
, rarefy = round(stats::bw.nrd0(x) * 1000)
.
With 100 <= rarefy <= 1000
.
Thomas Guillerme
Silverman, B. W. (1986) Density Estimation. London: Chapman and Hall.
variation.range
set.seed(1)
## Two distributions
x <- rnorm(10)
y <- runif(10)
## The area difference
area.diff(x, y)
## Visualising the difference
plot(sort(x), type = "l", col = "orange", lwd = 2)
lines(sort(y), col = "blue", lwd = 2)
polygon(c(1:10, 10:1), c(sort(x), sort(y, TRUE)), col = "grey", border = NA)
legend("topleft", legend = c("x", "y", "area difference"), col = c("orange", "blue", "grey"),
lty = c(1,1,0), pch = c(NA,NA,15))
## Two unequal distributions
z <- rnorm(100)
## The area difference estimation
area.diff(x, z)
## The area difference estimation with a fixed rarefaction value using the median
area.diff(x, z, rarefy = 500, cent.tend = median)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.