s-news
[Top] [All Lists]

Re: confidence ellipses

To: Pedram Sendi <psendi@uhbs.ch>
Subject: Re: confidence ellipses
From: Spencer Graves <spencer.graves@pdf.com>
Date: Thu, 18 Sep 2003 07:15:24 -0700
Cc: ripley@stats.ox.ac.uk, s-news@lists.biostat.wustl.edu
In-reply-to: <2003918212726.300292@ws508117>
References: <2003918212726.300292@ws508117>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
If you want exact ellipses corresponding to a specific bivariate normal, consider the following:
     Info <- array(c(2, 1,1,2), dim=c(2,2))
     Q.form <-
     function(x, y, mu=c(0, 1), Info.=Info){
         z0 <- (c(x, y)-mu)
Q. <- (t(z0) %*% Info %*% z0) }
###########
Info. = inverse of the covariance matrix. Put this into a loop to generate the grid of points to plot with contour or persp.
     hope this helps.  spencer graves

Pedram Sendi wrote:

Deal all
Further to my e-mail with respect to drawing confidence ellipses around 5000 pairs of values, I was not successful with kde2d. I am not sure whether this is the answer to my question (I realise that I did not provide sufficient information). Attached is a plot of the 5000 samples I have, which approximate a bivariate normal distribution (with a positive correlation). I'd be interested in fitting smooth ellipses that include 5%, 50% and 95% of the 5000 samples. I would be very grateful if someone could tell me how to do it in S-Plus (v 6.1 for win). Thanks a lot! Best,
Pedram
Pedram Sendi, MD, DSc
Institute for Clinical Epidemiology & Division of Infectious Diseases
Institut fur klinische Epidemiologie & Abteilung fur Infektiologie
Basel University Hospital
Kantonsspital Basel
Hebelstrasse 10, 3rd Floor
CH-4031 Basel
Switzerland
Phone: +41 61 265 31 02
Fax: +41 61 265 31 09
On Tue, 16 Sep 2003 09:44:12 +0100 (GMT Dayligh, Prof Brian D Ripley wrote:
>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.
------------------------------------------------------------------------

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


<Prev in Thread] Current Thread [Next in Thread>