ellipses

1,071 views
Skip to first unread message

Virgínia Morera

unread,
Feb 17, 2014, 4:24:32 PM2/17/14
to factomin...@googlegroups.com
Hi all, 

I'm aware that the problems with the ellipses have been discussed before in this group, but I haven't been able to find a solution to my particular problem, so here I go trying again. After performing a PCA to my data, I try to draw the ellipses around the results, and something weird happens. For the datasets where I have two supplementary qualitative variables (i.e. species and year), I get the graphic with the ellipses without any problem using the command  "plotellipses(results)" (The graphic is attached for clarity). But, for the datasets which have only one qualitative variable (i.e. year), when trying the exact same command, I get the following error message (translated from Spanish, so it might not be exactly what R says in English, but you get the idea): 

"Error in if (scale[1] > 0) r <- r/scale[1] : 
  missing value where TRUE/FALSE is needed"

I tried to draw the ellipses without using that command, like so: 

"aa <- cbind.data.frame(mydata[,1],results$ind$coord)
bb <- coord.ellipse(aa,bary=TRUE)
plot.PCA(results, axes=c(1,2), choix="ind",habillage=1,ellipse=bb)"

But I got the exact same error message. The problem is, so to speak, in the second step. I can create a dataframe called aa with the results of the PCA and the qualitative variable (first column) without problems, but when I try the coord.ellipse command, there it goes the error message again. 

Any ideas? 

Thank you very much! 

Virginia Morera. 



ellipses.jpeg

Arthur Riedel

unread,
Dec 8, 2014, 9:58:00 PM12/8/14
to factomin...@googlegroups.com
Hi Virginia

I'm sorry, I'm not sure how long your post has been up, but I've been having a similar problem recently. 

More by chance than design, I found one possible cause for this: if there is only one sample of a group in the data set, you will get the error you describe above.

I hope this turns out to be of some use to you even at this late stage.

All the best,
Arthur

Arthur Riedel

unread,
Dec 9, 2014, 7:43:43 PM12/9/14
to factomin...@googlegroups.com
Virginia

Another possibility is that the variable you are trying to draw ellipses for, if numeric, has not been identified as a factor (categorical). I just bumped into that myself!

Arthur

Virgínia Morera

unread,
Dec 12, 2014, 3:38:53 AM12/12/14
to factomin...@googlegroups.com
​​

​Hi Arthur! ​Thanks for taking the time to answering my question, even after all this time. I finally found a way around and finished what I was doing without the ellipses, because I never figured out what was wrong with my data. I have no groups with only one sample, but what I do have is a grouping variable (year) that has two levels for some groups and 3 for others. After your suggestion, I am thinking that sounds likely to be the problem! So thank you very much! 


Best, 


Virginia

El dia 09/12/2014 3:58, "Arthur Riedel" <sword...@gmail.com> va escriure:
--
Vous recevez ce message, car vous êtes abonné à un sujet dans le groupe Google Groupes "FactoMineR users".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/factominer-users/Z0q-5jgARX8/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
Message has been deleted

jan.o...@gmail.com

unread,
Mar 10, 2016, 9:11:26 AM3/10/16
to FactoMineR users
I had the same problem. As Arthur said it is the problem of having only one sample of a group. The way how to solve this is to remove this sample from ellipse.coord calculation and then if you apply this on PCA ellipse plotting it works nicely. 

In your case it would be something like this
aa <- cbind.data.frame(mydata[,1],results$ind$coord)
aa<-aa[duplicated(aa[1]) | duplicated(aa[1], fromLast=TRUE),] # Remove all unique values - there are there only once and cause troubles.
aa[1] <- factor(aa[[1]]) # Re-level the  "description" column
bb <- coord.ellipse(aa,bary=TRUE)
plot.PCA(results, axes=c(1,2), choix="ind",habillage=1,ellipse=bb)

Maybe it will help somebody in the future. 

Best,
 Jan

Dne pátek 12. prosince 2014 9:38:53 UTC+1 Virgínia Morera napsal(a):
Reply all
Reply to author
Forward
0 new messages