7
$\begingroup$

I'm trying to get some intuition for multivariate analysis. Thought it would be good to visualise, say, the .95 probability contour for a multivariate normal.

I'm looking for suggestions on an efficient way to do this in R.

My attempt was to generate a bunch of vectors $\boldsymbol v=(cos(x), sin(x))'$ for evenly spaced x in $[0,2\pi]$ and then try to manipulate the cdf to find what constant $k$ made $F(k*\boldsymbol v)=.95$ (when $\boldsymbol \mu = \boldsymbol0$ and $\boldsymbol \Sigma$ arbitrary).

Couldn't get this working and wondered if there was a better approach. I didn't have much luck with the R package I tried - mvtnorm - not sure what they mean by 'equicoordinate' quantile?

$\endgroup$
4
  • 2
    $\begingroup$ try the ellipse function in car. You have to set the radius to the square root of the desired quantile of the $\chi^2_{2}$... $\endgroup$
    – user603
    May 25 '13 at 15:04
  • 1
    $\begingroup$ It seems to me this question has been answered at stats.stackexchange.com/a/24393/919. Is there more that you need? $\endgroup$
    – whuber
    Nov 13 '13 at 15:45
  • $\begingroup$ Thanks but I didn't see the reasoning in the answers beyond giving some function (which is great, but what if I'm not working in R)? User603's suggestion and some development below and you can do it in other languages. $\endgroup$ Nov 19 '13 at 17:33
  • $\begingroup$ A generalisation to any dimension can be found at Equation (4) in: ism.ac.jp/editsec/aism/pdf/016_1_0135.pdf $\endgroup$
    – user156247
    Apr 6 '17 at 14:27
5
$\begingroup$

OK, scratching my own itch. We want the $1-\alpha$ level curve of $y \sim N_2(\mu,\Sigma)$

The $1-\alpha$ level curve of the $\mathcal N_2(0,I)$ distribution function is a circle of radius $\sigma = \sqrt{ \chi^2_{2,1-\alpha} }$ centred at the origin. This holds because if we consider some $x$ drawn from that distribution then $\mathbb P(x^T x \le \chi^2_{2,1-\alpha}) = 1-\alpha$.

Using this to get the comparable curve for $y$ is a case of applying a standard linear transformation to $x$.

Take some points on the unit circle by generating a sequence of angles, $\phi$, over $[0, 2\pi)$ and apply $(cos(\phi),sin(\phi))$, call the matrix formed by stacking these row vectors $R$.

$\tilde Y = R \sigma \Sigma^{1/2} + \mu$.

$\tilde Y$ is a set of points on the requisite level curve.

EDIT: Tidied up the notation in response to @whuber's comment, hope it's less incoherent now.

$\endgroup$
3
  • 1
    $\begingroup$ It is difficult to see how your claim that "$V \sim N(\mu,\Sigma)$" can be true: you selected $r$ points according to some arbitrary method and they all lie on a circle: there's just no way they have a normal distribution! What are the $x_i$, by the way? $\endgroup$
    – whuber
    Nov 18 '13 at 15:46
  • 1
    $\begingroup$ Much better, thank you! However, "$\Sigma^{1/2}$" is not well-defined: covariance matrices can have multiple distinct roots. See the "technical notes" at the end of stats.stackexchange.com/a/71303. Which root do you specifically have in mind? Or does it not matter? :-) (+1) $\endgroup$
    – whuber
    Nov 19 '13 at 18:22
  • $\begingroup$ Practically I used the square root derived from taking the eigendecomposition of $\Sigma$ and forming $\Sigma=\Gamma \Lambda^{1/2} \Gamma^T$. Thanks for taking another look too! $\endgroup$ Nov 20 '13 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.