Dear list I have a vector of values that allegedly have a bivariate normal distribution. I want to create a plot that shows the values I have obtained, and the bivariate normal distribution curve for the data. Is there a way of doing this in R? Many thanks for your help, Sarah. --------------------------------- [[alternative HTML version deleted]]
Dear Sarah, If the data are allegedly bivariate normal, then they are probably two vectors, not one. Assuming that this is the case, I know of nothing quite as neat as a univariate QQ plot to check visually for bivariate normality (perhaps someone else has a suggestion here), but you could superimpose bivariate-normal contours on a scatterplot of the data, perhaps along with a bivariate density estimate. The car and ellipse packages can do the former, while the locfit and sm packages (and possibly others) can do the latter. I hope this helps, John -------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox --------------------------------> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of sarah english > Sent: Saturday, October 23, 2004 7:34 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Plotting Bivariate Normal Data > > > Dear list > > I have a vector of values that allegedly have a bivariate > normal distribution. > > > > I want to create a plot that shows the values I have > obtained, and the bivariate normal distribution curve for the data. > > > Is there a way of doing this in R? > > > > > Many thanks for your help, > > Sarah. > > > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
John Fox wrote:>Dear Sarah, > >If the data are allegedly bivariate normal, then they are probably two >vectors, not one. Assuming that this is the case, I know of nothing quite as >neat as a univariate QQ plot to check visually for bivariate normality >(perhaps someone else has a suggestion here), but you could superimpose > >What about using Independent component analysis to find the most non-normal linear combination and make a qq-plot of that? Something like: library(fastICA) # on CRAN x <- matrix(rchisq(10000, df=2), 1000, 10) P <- svd(matrix(rnorm(100), 10,10))$u # random orthogonal matrix y <- x %*% P y.ica <- fastICA(y, 2) qqnorm(y.ica$S[,1]) But I have never seen this suggested in print, although it seems quite natural. Anybody knows if something like this is considered a reasonable test of multivariate normality? Kjetil>bivariate-normal contours on a scatterplot of the data, perhaps along with a >bivariate density estimate. The car and ellipse packages can do the former, >while the locfit and sm packages (and possibly others) can do the latter. > >I hope this helps, > John > >-------------------------------- >John Fox >Department of Sociology >McMaster University >Hamilton, Ontario >Canada L8S 4M4 >905-525-9140x23604 >http://socserv.mcmaster.ca/jfox >-------------------------------- > > > >>-----Original Message----- >>From: r-help-bounces at stat.math.ethz.ch >>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of sarah english >>Sent: Saturday, October 23, 2004 7:34 AM >>To: r-help at stat.math.ethz.ch >>Subject: [R] Plotting Bivariate Normal Data >> >> >>Dear list >> >>I have a vector of values that allegedly have a bivariate >>normal distribution. >> >> >> >>I want to create a plot that shows the values I have >>obtained, and the bivariate normal distribution curve for the data. >> >> >>Is there a way of doing this in R? >> >> >> >> >>Many thanks for your help, >> >>Sarah. >> >> >> >> >>--------------------------------- >> >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide! >>http://www.R-project.org/posting-guide.html >> >> > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > > >-- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra
Just a little addendum to Martin's comments below. It is well known that using LS centers and covariances for the M-distances is generally not a good way to do this, as these statistics, themselves, are distorted by the long "tails" (do > 1D distributions have "tails"?) so that the problems are hidden (see Brian Ripley's comments on the R-Help "robust regression with groups" thread from last week). Hence, one should use a resistant center (the medioid, say) and a resistant covariance matrix (e.g., from cov.rob()) to compute the M-distances. ... But then, this begs the question: Why do normality testing at all? (again, see BR's comments). Better to use robust/resistant statistical procedures for estimation from the beginning, though, unfortunately, this shatters the nice simple mathematical framework for inference. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> Since one of the more severe and common deviations from > normality is "long tailed"ness (in all it's vaguety), we have > been recommending to QQ-plot mahalanobis distances against chi > squared quantiles - even before looking at the univariate > QQ plots. > > Exactly for this reason, in R, > example(mahalanobis) > shows a version of how to do this! > > Martin Maechler, ETH Zurich > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
> From: Berton Gunter > > Just a little addendum to Martin's comments below. It is well > known that > using LS centers and covariances for the M-distances is > generally not a good > way to do this, as these statistics, themselves, are > distorted by the long > "tails" (do > 1D distributions have "tails"?)How about `long skirt' or some such? That seems descriptive, at least for 2D... Andy> so that the problems are > hidden (see Brian Ripley's comments on the R-Help "robust > regression with > groups" thread from last week). Hence, one should use a > resistant center > (the medioid, say) and a resistant covariance matrix (e.g., > from cov.rob()) > to compute the M-distances. > > ... But then, this begs the question: Why do normality testing at all? > (again, see BR's comments). Better to use robust/resistant statistical > procedures for estimation from the beginning, though, > unfortunately, this > shatters the nice simple mathematical framework for inference. > > -- Bert Gunter > Genentech Non-Clinical Statistics > South San Francisco, CA > > "The business of the statistician is to catalyze the > scientific learning > process." - George E. P. Box > > > > > Since one of the more severe and common deviations from > > normality is "long tailed"ness (in all it's vaguety), we have > > been recommending to QQ-plot mahalanobis distances against chi > > squared quantiles - even before looking at the univariate > > QQ plots. > > > > Exactly for this reason, in R, > > example(mahalanobis) > > shows a version of how to do this! > > > > Martin Maechler, ETH Zurich > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >