Description Usage Arguments Value Author(s) References See Also Examples
View source: R/plot.hdr.conf.R
Plots Highest Density Regions with confidence intervals.
1 2 |
x |
Output from |
den |
Density of data as list with components |
... |
Other arguments are passed to plot. |
None
Rob J Hyndman
Hyndman, R.J. (1996) Computing and graphing highest density regions American Statistician, 50, 120-126.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | x <- c(rnorm(100,0,1),rnorm(100,4,1))
den <- density(x,bw=bw.SJ(x))
trueden <- den
trueden$y <- 0.5*(exp(-0.5*(den$x*den$x)) + exp(-0.5*(den$x-4)^2))/sqrt(2*pi)
sortx <- sort(x)
par(mfcol=c(2,2))
for(conf in c(50,95))
{
m <- hdrconf(sortx,trueden,conf=conf)
plot(m,trueden,main=paste(conf,"% HDR from true density"))
m <- hdrconf(sortx,den,conf=conf)
plot(m,den,main=paste(conf,"% HDR from empirical density\n(n=200)"))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.