Hi Rafael, You need to mean-center your traits before multiplying by the matrix of eigenvectors. Compute the vector of phylogenetic means (under BM or Pagel’s lambda), subtract each value from the relevant column of Xm and then compute Si. The result should be identical to the scores from your phylogenetic PCA.
Graham ------------------------------------------------------ Graham J. Slater Assistant Professor Department of the Geophysical Sciences University of Chicago 5734 S. Ellis Avenue Chicago, IL 60637 USA Tel: (773) 702-0249 email: gsla...@uchicago.edu<mailto:gsla...@uchicago.edu> www.fourdimensionalbiology.com<http://www.fourdimensionalbiology.com> On Mar 12, 2018, at 11:11 AM, Rafael S Marcondes <raf.marcon...@gmail.com<mailto:raf.marcon...@gmail.com>> wrote: Hi Liam, Thank you very much for the very fast response (as usual). To try out if I was using your approach correctly, I ran it with the species-level data, expecting that I would get the same PC scores as from phyl.PCA. That didn't happen though. Am I understanding/doing something wrong? pca<-phyl.pca(tree,Xm) Si<-Xm%*%pca$Evec Expected that Si would be identical to pca$S. But they aren't. I have attached my species-level data, individual-level data, and output of phyl.pca Thank you, -- Rafael Sobral Marcondes PhD Candidate (Systematics, Ecology and Evolution/Ornithology) Museum of Natural Science<http://sites01.lsu.edu/wp/mns/> Louisiana State University 119 Foster Hall Baton Rouge, LA 70803, USA Twitter: @brown_birds<https://twitter.com/brown_birds> On Sun, Mar 11, 2018 at 5:16 PM Liam J. Revell <liam.rev...@umb.edu<mailto:liam.rev...@umb.edu>> wrote: Hi Rafael. So far as I know, there is currently no way to explicitly take into account sampling error in computing principal components while also accounting for the phylogeny. However, it is relatively straightforward to compute scores for individuals from a PCA conducted on species means. This would look as follows (in which Xm is a matrix containing values for species for each trait, and Xi is a matrix with the same number of columns but containing values for individuals): pca<-phyl.pca(tree,Xm) Si<-Xi%*%pca$Evec Then, if you have a separate vector containing species ID as a factor, you could compute means and variances for each component by species. I hope this is some help. All the best, Liam Liam J. Revell, Associate Professor of Biology University of Massachusetts Boston & Profesor Asociado, Programa de Biología Universidad del Rosario web: http://faculty.umb.edu/liam.revell/ On 3/11/2018 5:06 PM, Rafael S Marcondes wrote: > Dear all, > > Does anyone have any advice on how to calculate measurement error in an > analysis using phylogenetic principal components? Or, in other words, after > I run a phylogenetic PCA on species-level data, how can I "project" my > individual-level data into the phylogenetic PCs so I can calculate a > standard error? I'm running my pPCA using the lambda method and the > covariance matrix. > > I would think this would be an usual, simple procedure, and that there > would be an R function for it, but I can't for the life of me find > anything. The recent paper by Jonathan Drury et al linked below does > mention doing it, but without going into any detail. > > http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.2003563 > > Thank you very much for any help, > > > *--* > *Rafael Sobral Marcondes* > PhD Candidate (Systematics, Ecology and Evolution/Ornithology) > > Museum of Natural Science <http://sites01.lsu.edu/wp/mns/> > Louisiana State University > 119 Foster Hall > Baton Rouge, LA 70803, USA > > Twitter: @brown_birds <https://twitter.com/brown_birds> > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-phylo mailing list - > R-sig-phylo@r-project.org<mailto:R-sig-phylo@r-project.org> > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo > Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ > <indivdata.RDS><spleveldata.RDS><pPCAresults.rds>_______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org<mailto:R-sig-phylo@r-project.org> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ [[alternative HTML version deleted]] _______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/