[R] How to create density ellipses with R

John Fox j|ox @end|ng |rom mcm@@ter@c@
Fri Jan 14 19:53:55 CET 2022


Dear Paul,

On 2022-01-14 1:17 p.m., Paul Bernal wrote:
> Dear John and R community friends,
> 
> To be a little bit more specific, what I need to accomplish is the 
> creation of a confidence interval ellipse over a scatterplot at 
> different percentiles. The confidence interval ellipses should be drawn 
> over the scatterplot.

I'm not sure what you mean. Confidence ellipses are for regression 
coefficients and so are on the scale of the coefficients; data 
(concentration) ellipses are for and on the scale of the explanatory 
variables. As it turns out, for a linear model, the former is the 
rescaled 90 degree rotation of the latter.

Because the scatterplot of the (two) variables has the variables on the 
axes, a data ellipse but not a confidence ellipse makes sense (i.e., is 
in the proper units). Data ellipses are drawn by car::dataEllipse() and 
(as explained by Martin Maechler) cluster::ellipsoidPoints(); confidence 
ellipses are drawn by car::confidenceEllipse() and the various methods 
of ellipse::ellipse().

I hope this helps,
  John

> 
> Any other guidance will be greatly appreciated.
> 
> Cheers,
> 
> Paul
> 
> El vie, 14 ene 2022 a las 11:27, John Fox (<jfox using mcmaster.ca 
> <mailto:jfox using mcmaster.ca>>) escribió:
> 
>     Dear Paul,
> 
>     As I understand it, the ellipse package is meant for drawing confidence
>     ellipses, not density (i.e., data) ellipses. You should be able to use
>     ellipse::ellipse() to draw a bivariate-normal density ellipse (assuming
>     that's what you want), but you'll have to do some computation first.
> 
>     You might find the dataEllipse() function in the car package more
>     convenient (again assuming that you want bivariate-normal density
>     contours).
> 
>     I hope this helps,
>        John
> 
>     -- 
>     John Fox, Professor Emeritus
>     McMaster University
>     Hamilton, Ontario, Canada
>     web: https://socialsciences.mcmaster.ca/jfox/
>     <https://socialsciences.mcmaster.ca/jfox/>
> 
>     On 2022-01-14 10:12 a.m., Paul Bernal wrote:
>      > Dear R friends,
>      >
>      > Happy new year to you all. Not quite sure if this is the proper
>     place to
>      > ask about this, so I apologize if it is not, and if it isn´t,
>     maybe you can
>      > point me to the right place.
>      >
>      > I would like to know if there is any R package that allows me to
>     produce
>      > density ellipses. Searching through the net, I came across a
>     package called
>      > ellipse, but I'm not sure if this is the one I should use.
>      >
>      > Any help and/or guidance will be greatly appreciated.
>      >
>      > Best regards,
>      >
>      > Paul
>      >
>      >       [[alternative HTML version deleted]]
>      >
>      > ______________________________________________
>      > R-help using r-project.org <mailto:R-help using r-project.org> mailing list
>     -- To UNSUBSCRIBE and more, see
>      > https://stat.ethz.ch/mailman/listinfo/r-help
>     <https://stat.ethz.ch/mailman/listinfo/r-help>
>      > PLEASE do read the posting guide
>     http://www.R-project.org/posting-guide.html
>     <http://www.R-project.org/posting-guide.html>
>      > and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list