[R] Ellipse that Contains 95% of the Observed Data
Ben Bolker
bolker at ufl.edu
Mon Mar 29 05:02:02 CEST 2010
Tom La Bone <booboo <at> gforcecable.com> writes:
>
>
> I can take the results of a simulation with one random variable and generate
> an empirical interval that contains 95% of the observations, e.g.,
>
> x <- rnorm(10000)
> quantile(x,probs=c(0.025,0.975))
>
> Is there an R function that can take the results from two random variables
> and generate an empirical ellipse that contains 95% of the observations,
> e.g.,
>
> x <- rnorm(10000)
> y <- rnorm(10000)
> ?
>
> I am specifically looking for an ellipse that does not assume normality.
I'll be interested to hear what others come up with.
I'm not sure the problem as you have stated it is well-posed, or
necessarily possible. Suppose there is a true unknown
bivariate probability distribution with a non-elliptical 95%
quantile region. Will you be able to draw an ellipse that
has the properties you want?
Here's one possible alternative:
library(coda)
library(emdbook)
plot(x,y)
z = HPDregionplot(as.mcmc(cbind(x,y)),add=TRUE,col=2,lwd=2)
is not an ellipse, but does contain (approximately) 95% of
the points.
Convex hulls are another plausible approach.
More information about the R-help
mailing list