On Tue, 16 Sep 2003, Pedram Sendi wrote:
> I have approximated a bivariate distribution f(a,b) using simulation, i.e.
> I have 5000 values of pairs of a,b. I would now like to plot a smooth 95%
> confidence ellipse, 50% confidence ellipse and 5% confidence ellipse. The
> contour plot feature does not seem to work. I would be very grateful if
> someone could tell me how to accomplish this in S-Plus 6.1 for Windows.
So you approximated a density by 5000 point values? That's not a very good
approximation! What makes you think that there is a confidence ellipse (as
distinct from any other shape of region)? And do you mean a confidence
region, which needs a parametrized model?
What I can help with is finding a contour plot of the underlying density.
First find a 2d density estimate (using e.g. kde2d in MASS or the functions
in KernSmooth), and compute the density values of your 5000 points, and
sort them. Then the 5%, 50% and 95% quantiles of those density values can
be used as contour levels for a plot of the density estimate (evaluated at
a rectangular grid). That's the best interpretation I can find of your
intentions. You will find relevant examples in MASS (the book).
An alternative interpretation would be to assume a bivariate normal or t
distribution (which have elliptical contours), fit that and then plot the
appropriate density contours.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|