r - How to add CI whiskers to a rarefaction curve -
i need make rarefaction curves , wish them display whiskers @ edges of confidence interval bars, whereas default display bars without whiskers:
library(vegan) data("dune") result <- specaccum(dune) plot(result, lwd=2) i've tried add whiskers using arrows function, results specaccum function include standard deviation. ended half job done:
samples <- result$sites error <- result$sd richness <- result$richness arrows(samples, richness-error, samples, richness+error, angle=90, code=3, length=0.05) from i've searched, common approach convert confidence intervals shaded area (by using argument ci.type="polygon") , add boxplot plotted curve. however, leads busy image i'd rather avoid.
does have more elegant solution?
you forgot multiplier (see argument ci in ?plot.specaccum). drew ~68% confidence interval. multiplying 2 (ci = 2) gives approximate 95% confidence interval, plot.specaccum draws default.
including (default) multiplier in modification of code used
plot(result) with(result, arrows(sites, richness - (2 * sd), sites, richness + (2 * sd), angle = 90, code = 3, length = 0.05)) we get:
you can ignore warning; standard error of last data point drawn zero
> result$sd [1] 2.3510636 1.8763851 1.5722711 1.4469584 1.3901594 1.3530349 1.3164796 [8] 1.2749034 1.2282010 1.1763410 1.1193437 1.0564537 0.9874094 0.9115998 [15] 0.8286890 0.7380921 0.6333903 0.5139710 0.3570714 0.0000000 and arrow() warning won't draw length 0 arrow.



Comments
Post a Comment