Hi, I created a principal component plot using the first two principal components. I used the function princomp() to calculate the scores. now, I would like to superimpose an ellipse representing the center and the 95% confidence interval of a series of points in my plot (as to illustrate the grouping of my samples). I looked at the ellipse() function in the ellipse package but can't get it to work. the princomp()-function gives me the scores of each point, so I can calculate the mean and the 95%-CI, but I can't integrate this into the ellipse()-function). Is there a better way of doing this or can someone help me figure out this function? best regards, Lukas
Dear Lukas, You might try the dataEllipse() function in the car package. I hope this helps, John> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of Lukas Baitsch > Sent: June-06-11 10:33 AM > To: r-help at r-project.org > Subject: [R] adding an ellipse to a PCA plot > > Hi, > > I created a principal component plot using the first two principal > components. I used the function princomp() to calculate the scores. > now, I would like to superimpose an ellipse representing the center and > the 95% confidence interval of a series of points in my plot (as to > illustrate the grouping of my samples). > > I looked at the ellipse() function in the ellipse package but can't get > it to work. the princomp()-function gives me the scores of each point, > so I can calculate the mean and the 95%-CI, but I can't integrate this > into the ellipse()-function). Is there a better way of doing this or can > someone help me figure out this function? > > best regards, > > Lukas > > ______________________________________________ > 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.
Hi, I think the easiest way is to use the function plotellipses of the FactoMineR package (but you have to do your PCA with the PCA function included in this package). Alain On 06-Jun-11 16:32, Lukas Baitsch wrote:> Hi, > > I created a principal component plot using the first two principal > components. I used the function princomp() to calculate the scores. > now, I would like to superimpose an ellipse representing the center > and the 95% confidence interval of a series of points in my plot (as > to illustrate the grouping of my samples). > > I looked at the ellipse() function in the ellipse package but can't > get it to work. the princomp()-function gives me the scores of each > point, so I can calculate the mean and the 95%-CI, but I can't > integrate this into the ellipse()-function). Is there a better way of > doing this or can someone help me figure out this function? > > best regards, > > Lukas > > ______________________________________________ > 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. >-- Alain Guillet Statistician and Computer Scientist SMCS - IMMAQ - Universit? catholique de Louvain http://www.uclouvain.be/smcs Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 Acc?s: http://www.uclouvain.be/323631.html