Closed lilyb3 closed 8 months ago
Hi @lilyb3. I tried trouble-shooting this for you with simulated data & was able to get a for
loop working without too much difficulty. Perhaps if you send or post your files I may be able to help more. -- Liam
Please re-open if you still need help with this issue.
I would like to calculate the phylogenetic signal for 2001 traits in a for loop with 81 taxa. I had no problem calculating the phylogenetic signal using Blomberg's K, but the code for lambda produces an error.
Here is what I've done for K: for(i in 1:ncol(traits)){ trialtrait<-setNames(traits[,i], rownames(traits)) st_error <- setNames(se.dn[,i], rownames(se.dn)) phylosig_mean[[i]] <- phylosig(tree_pruned,trialtrait, test=TRUE,nsim=10000, se=st_error) trialtrait <- NULL st_error <-NULL }
Here is what I have tried to do for lambda:
for(i in 1:ncol(traits)){ trialtrait<-setNames(traits[,i], rownames(traits)) st_error <- setNames(se.mean.dn1[,i], rownames(se.mean.dn1)) phylosiglambda_mean[[i]] <- phylosig(tree_pruned,trialtrait, method="lambda", test=TRUE, se=st_error, start= c(meansig2[i], meanKval[i]))
trialtrait <- NULL st_error <-NULL }
I've gotten the following errors:
So far, I've tried to change the following with lambda but nothing seems to work :
I've tried troubleshooting with ChatGPT quite a bit but nothing seems to work. Do you have any suggestions? Thank you!