Hi Vincenzo.
I can't say if this is a *good* idea or not, but if you are going to do
it, then you might want to use phytools:phylosig instead of
fitContinuous as it runs much faster (at least, relative to the present
version of 'geiger'), e.g.:
nn<-100 # number of reps
lambda<-phylosig(tree,x,method="lambda")$lambda # obs. lambda
# lambda from randomized tips
ff<-function(x){ x$tip.label<-sample(x$tip.label); x }
ll<-replicate(nn-1,phylosig(ff(tree),x,method="lambda")$lambda)
p<-mean(c(lambda,ll)>=lambda) # p.value from randomization
All the best, Liam
Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org
On 4/12/2013 9:50 PM, Ellis, Vincenzo A. (UMSL-Student) wrote:
Hi everyone,
I want to compare Pagel's lambda for phylogenetic signal in a given trait
against randomized lambdas by doing a tip shuffle on my tree of interest and
recalculating lambda each time. I know people often compare an observed lambda
value with a lambda of zero or 1, but I figured this might be another (perhaps
more straightforward?) way to do it. I tried to write a wrapper for the
fitContinuous function in geiger. I would appreciate it if someone could take a
quick look at it and see if it's valid or provide some feedback, as I don't
remember seeing this done before. Thanks so much!
library(geiger)
library(picante)
lambda_shuffle <- function(phylogeny, trait, reps){
observed.lambda <- (fitContinuous(phy=phylogeny, dat=trait,
model="lambda"))$opt$lambda
tipsh <- replicate(reps, (fitContinuous(phy=tipShuffle(phylogeny), dat=trait,
model="lambda"))$opt$lambda)
mean.tipsh <- mean(tipsh)
p.tipsh <- (reps + 2 - rank(c(observed.lambda, tipsh))[1])/(reps+1)
results <- data.frame(observed.lambda, mean.randomized.lambda = mean.tipsh,
P.value = p.tipsh)
return(results)
}
Vincenzo
[[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/
_______________________________________________
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/