Getting started with Rphylopars


Step 1: Get the most recent version of Rphylopars


require(devtools)
install_github("ericgoolsby/Rphylopars",ref = "devel",dependencies = TRUE)

# Un-comment and run the following if the above code doesn't work
# library(RCurl)
# library(httr)
# set_config( config( ssl_verifypeer = 0L ) )
# install_github("ericgoolsby/Rphylopars",ref = "devel",dependencies = TRUE)


Step 2: Format the data and tree

The tree should be a phylogenetic tree of class "phylo". Format the data variable as a data frame with 2 or more columns:

column 1 (labeled "species") with species names (must match tip names in phylogenetic tree)
column 2 (labeled with the name of trait 1 -- e.g., "body_mass") filled with trait data
column 3 (labeled with the name of trait 2 -- e.g., "range_size") filled with trait data
...
column m+1 (labeled with the name of trait m -- e.g., "fecundity") filled with trait data

Each row corresponds to an individual if pheno_correlated=TRUE. Otherwise, trait values are assumed to be independent.

Alternatively, simulate data (and tree) with the simtraits function: sim_data <- simtraits(ntaxa = 15,ntraits = 4,nreps = 3,nmissing = 15)


Step 3: Estimate phylogenetic and phenotypic covariance matrices via restricted maximum likelihood (REML)

PPE <- phylopars(trait_data = sim_data$trait_data, tree = sim_data$tree)

By default, Brownian motion is assumed, phenotypic (within-species) variance is estaimated, and phenotypic covariance is estimated. Let's fit a multivariate Ornstein-Uhlenbeck model of trait evolution:

PPE_OU <- phylopars(trait_data = sim_data$trait_data, tree = sim_data$tree, model = "mvOU")

Compare BIC values for PPE and PPE_EB models (lower is better):
BIC(PPE)
BIC(PPE_OU)


Step 4: Examine reconstructed ancestral states and imputed tip values

PPE$anc_recon