Thursday, May 26, 2011

New function: phylogenetic paired t-test

I just posted code for a new function that conducts the phylogenetic paired t-test of Lindenfors et al. (2010; of which I am also a co-author). Since I am out in the field here on Staniel Cay Exuma, in the Bahamas, it is somewhat difficult for me to error check, etc., so I leave that to my readers. . . . Just kidding, I'm pretty sure there is no major problems with this function, but I am (as always) happy to hear any feedback.

The phylogenetic paired t-test we used in our study was really pretty simple. Basically, we just computed the so-called "phylogenetic mean" for the difference between two values in each species (in our study, these were physiological measures collected from males and females of primates), and we asked if the mean difference was significantly different from zero. In addition, we also incorporated uncertainty about the species means for each trait (essentially following Ives et al. 2007); and we optimized Pagel's λ for the difference.

To use the function, first download it (my R-phylogenetics page; direct link to code here) and load from source; then type:

> result<-phyl.pairedttest(tree,x1,x2)

The result is a list which contains the mean difference, the optimized value of lambda, and some other things.

With a little creativity, this function can also be used to test the hypothesis that the phylogenetic mean for a single trait or a difference between traits is significantly different from an arbitrary value; or to evaluate the phylogenetic signal for a single trait or the difference between two traits.

More soon. . . .

4 comments:

  1. cool to see you found the time to work on this, thanks! For some of my variables, the results for that function I had are close, but for others they're really different; so I guess I was pretty off. Still, was a good practice. So, once more, thanks!

    ReplyDelete
  2. Pretty cool little function! Thanks very much for it!
    Do you have any non-parametric test like this by the way? E.g. phylogenetic paired wilcoxon test?

    ReplyDelete
  3. Dear Liam,
    I have encountered a strange problem with this function. When I use phyl.pairttest lambda is not optimised properly. It always takes a value close to the initial lamba settings. Is there a way to deal with this problem? How can I increase number of iterations when lambda is optimised? I have data on 194 speices, so small sample size shouldn't be the problem. My phytools version is 0.5.0.

    Your help would be much appreciated.

    Best,
    Anna

    ReplyDelete
  4. Hi Liam-
    I have a very basic question. What is the format for the phylogenetic tree to be loaded into phytools to do this analysis? How do I get the trait values for the two traits in the paired t-test to match up to their corresponding species in the tree?
    I am working with a small tree- only 17 taxa- but I can't figure out this step.
    Sorry- I know this is really entry level stuff, but I could not find instructions for this basic (but critical!) step in any online documentation.
    Thanks- I am excited to see that this analysis may be possible.

    ReplyDelete

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.