[R] calculating/plotting error ellipses

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 25 20:12:05 CEST 2007


On Tue, 25 Sep 2007, Jan M. Wiener wrote:

> Hello,
> thank you very much for the quick answer.
> This works well. it draws a nice ellipse in the right orientation.
> However, I  doubt that the ellipse represents the 95% confidence
> interval, even if that is the standard-parameter for level is .95. The
> ellipse surely is to large?

It isn't supposed to.  You need to tell us what you mean by 'the 
corresponding error ellipse'.  If you want to plot a confidence region for 
the mean vector, you need to rescale the variance 'v' to be the variance 
of the mean and not of the data.  However, with as few obs as you have (as 
I recall it was 12), the normal-based confidence region is not at all 
accurate and you might need to take the estimation of 'v' into account.

My best guess was that you were looking for a tolerance region, which is 
none of the above.  But the posting guide is there to avoid potential 
helpers being put off answering by the need to guess.


> Any further help would be greatly appreciated.
> Best,
> Jan
>
>
> bbolker wrote:
>>
>> Jan M. Wiener wrote:
>>
>>> hello,
>>> sorry for posting what may be a simple question:
>>> i do have a matrix of coordinates (positional judgments, see below) and
>>> now want to calculate and plot the corresponding error ellipse.
>>> can anyone help me with the exact steps/syntax?
>>>
>>>
>>
>> Something along the lines of:
>>
>> m = colMeans(xyDat)  # calc. column means
>> v = var(xyDat)             # compute var-cov matrix
>> library(ellipse)              # you may need install.packages("ellipse")
>> first
>> plot(ellipse(v,centre=m),type="l")   ## draw the confidence ellipse
>> points(m[,1],m[,2])     # add the cent(re|er) point
>>
>>   Of course, I haven't actually tested this ...
>>
>>   Ben Bolker
>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at 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



More information about the R-help mailing list