Hi Ted.
Yes, good point.
I also pointed out in my message that the correlation should be exactly the same when the error matrix V is a covariance matrix obtained under pure BM. In Christian's code, however, he also fits Pagel's lambda (using the function corPagel) - which means that his correlation will not be the same as in IC if lambda~=1.0. Furthermore, he calculates V as a correlation matrix (rather than covariance matrix), which means that his correlation will not be the same as for IC if the tree is not ultrametric (and his is nearly, but not precisely, ultrametric), even if lambda is set to 1.0. However, for the conditions where V is the covariance matrix obtained under BM (i.e., V<-vcv.phylo(tree.orig); V<-V[order(dimnames(V)[[1]]),order(dimnames(V)[[2]])];) then the correlation from IC will be the same as from PGLS.
I hope this clarifies my earlier message!
Thanks, Liam

Liam J. Revell
NESCent, Duke University
web: http://anolis.oeb.harvard.edu/~liam/
NEW email: lrev...@nescent.org



tgarl...@ucr.edu wrote:
Maybe I am missing something here, but as IC = GLS, the correlation coefficient is the same. GLS will not give you anything different.

Cheers,
Ted

Theodore Garland, Jr., Ph.D.
Professor
Department of Biology
University of California
Riverside, CA 92521
Phone:  (951) 827-3524 = Ted's office (with answering machine)
Phone:  (951) 827-5724 = Ted's lab
Phone:  (951) 827-5903 = Dept. office
Home Phone:  (951) 328-0820
FAX:  (951) 827-4286 = Dept. office
Email:  tgarl...@ucr.edu
http://biology.ucr.edu/people/faculty/Garland.html
List of all publications with PDF files:
http://biology.ucr.edu/people/faculty/Garland/GarlandPublications.html

Garland, T., Jr., and M. R. Rose, eds. 2009. Experimental evolution: concepts, methods, and applications of selection experiments. University of California Press, Berkeley, California. http://www.ucpress.edu/books/pages/10604.php

Associate Director
Network for Experimental Research on Evolution
http://nere.bio.uci.edu/
(A University of California Multicampus Research Project)

---- Original message ----
Date: Sun, 27 Dec 2009 22:06:21 -0500
From: r-sig-phylo-boun...@r-project.org (on behalf of "Liam J. Revell"
<lrev...@nescent.org>)
Subject: Re: [R-sig-phylo] Estimate correlation coefficient of a linear GLS model To: Christian Arnold <chrarn...@web.de>
Cc: r-sig-phylo@r-project.org

Hi Christian,

There was a previous discussion on the coefficient of determination (R^2) for PGLS. It can be found in the Oct-2009 R-sig-phylo archive, here: https://stat.ethz.ch/pipermail/r-sig-phylo/2009-October/thread.html.

Maybe you could also calculate a "generalized correlation coefficient" as follows (for your case):

V<-corMatrix(Initialize(corStr,DF)); # this gets the correlation matrix
>from corStr (I'm not sure this is precisely right in general)
a.FemMass<-matrix(1,1,5)%*%solve(V)%*%FemMass/sum(solve(V)); # this computes the "phylogenetic mean" from FemMass a.HomeRange<-matrix(1,1,5)%*%solve(V)%*%HomeRange/sum(solve(V)); # this computes the same from HomeRange
# this computes the generalized correlation coefficient
r.gls<-(FemMass-a.FemMass)%*%solve(V)%*%(HomeRange-
a.HomeRange)/sqrt(((FemMass-a.FemMass)%*%solve(V)%*%(FemMass-
a.FemMass))*((HomeRange-a.HomeRange)%*%solve(V)%*%(HomeRange-a.HomeRange)));
Incidentally, this for an ultrametric tree (yours is close to ultrametric, but not precisely so) and lambda=1;
OR for the following:
V<-vcv.phylo(tree.orig); V<-V[order(dimnames(V)[[1]]),order(dimnames(V)[[2]])]; # to order rows and columns; the previous calculations will give you exactly the same correlation coefficient as:

pic.FemMass<-pic(FemMass,tree.orig);
pic.HomeRange<-pic(HomeRange,tree.orig);
r.pic<-cor.origin(pic.FemMass,pic.HomeRange);

Try it. - Liam

Liam J. Revell
NESCent, Duke University
web: http://anolis.oeb.harvard.edu/~liam/
NEW email: lrev...@nescent.org



Christian Arnold wrote:
Hello,

I received great support in the past in this mailing list, and I hope that someone knows the answer to the following question as well:


I want to estimate the correlation coefficient (r) for two continuous characters X and Y using phylogenetically independent contrasts (PIC) and phylogenetically generalized least squares (PGLS) (with the gls function in the nlme package) for a given phylogeny and model of evolution. This is easy for PIC (using the pic function from the APE package and cor.origin for example), but I am having troubles with PGLS. The gls function fits a linear model using generalized least squares and returns estimates for the coefficients of the linear regression, but I don't see an estimate of r (the correlation of X and Y) and I am not sure how to do that in the GLS case...

Here some code that can be pasted into R directly:
____________________________________________________________________
library(ape)
library(nlme)
FemMass=c(80,3.3,3.3,40,37)
HomeRange=c(3200,42,39,1250,410)
names(HomeRange) <- names(FemMass) <- c("a","b","c","d","e")

tree.orig =read.tree(text="(((a:9.35,d:9.35):7.05,e:16.5):14.51,(b:4.8,c:4.8):26.16):64.2;")
corStr <- corPagel(value = 1,phy = tree.orig, fixed=F)
DF <- data.frame(HomeRange,FemMass)

m1 <- gls(HomeRange ~ FemMass, correlation = corStr,data = DF)
summary(m1)
____________________________________________________________________

If anyone knows how I can calculate r here, I would appreciate any help...

Thanks,
Christian

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to