bammdata object and a vector of trait data (continuous), assess whether the correlation between the trait and bamm estimated speciation , extinction or net diversification rate is significant using permutation. A set of posterior samples is randomly drawn from the bammdata object. If the trait is continuous, this function calculates the correlation coefficients between the trait and tip rates (observed correlation), as well as that with permuted rates for each posterior sample. In a one-tailed test for positive correlations, the reported p-value is the proportion of the posterior samples in which the observed correlation is larger than the correlations calculated with permuted rates. In a two-tailed test, the reported p-value is the proportion of the posterior samples in which the null correlation is as extreme as the correlation observed. If the trait is binary, the U statistic of the Mann-Whitney test is calculated instead of correlation coefficients to assess whether there is a significant difference in rate between the two trait states. For categorical traits with more than two states, the Kruskal-Wallis rank sum statistic is used.traitDependentBAMM(ephy, traits, reps, rate = 'speciation', return.full = FALSE,
method = 'spearman', logrates = TRUE, two.tailed = TRUE,
traitorder = NA, nthreads = 1)bammdata.bammdata object. It can be numeric or categorical.bammdata object)bammdata object to use for testing correlation, must be one of 'speciation', 'extinction', or 'net diversification'. Defaults to 'speciation'. You can specify just the initial letterTRUE, the list of posterior samples, the observed correlation for each posterior sample, and the null distribution will be included in the returned object. Defaults to FALSE.TRUE log-transform the rates before analysis. Defaults to TRUE. This can only matter for the pearson correlation.TRUE, perform a two tailed statistical test (i.e., if the null distribution is symmetric, it is equivalent to doubling the p-value). Defaults to TRUE.snow must be loaded for nthreads > 1.return.full is TRUE.return.full is TRUE. For binary traits, centered U statistics (U - n1* n2/2; where n1 and n2 are the number of species in each state of the binary trait) is reportedreturn.full is TRUE.tipStates still have the same rate after permutation. Posterior samples are randomly selected with replacement from the bammdata object, so reps could be smaller or larger than the total number of samples in the object.Rabosky, D. L. 2014. Automatic detection of key innovations, rate shifts, and diversity-dependence on phylogenetic trees. PLoS ONE 9:e89543
Rabosky, D. L., F. Santini, J. T. Eastman, S. A. Smith, B. L. Sidlauskas, J. Chang, and M. E. Alfaro. 2013. Rates of speciation and morphological evolution are correlated across the largest vertebrate radiation. Nature Communications DOI: 10.1038/ncomms2958
subtreeBAMM# using a small subset of the fish data set (300 taxa) in Rabosky et al. 2013. Nat. Com. paper
data(fishes, events.fishes)
xx <- getEventData(phy = fishes, eventdata = events.fishes,
nsamples = 500, type = "diversification")
#traits.fishes is the trait -- body size
data(traits.fishes)
x <- traitDependentBAMM(ephy = xx, traits = traits.fishes, reps = 1000, return.full = TRUE,
method = 's', logrates = TRUE, two.tailed = TRUE)Run the code above in your browser using DataLab