Skip to content

Function to estimate evolutionary parameter in PGLS models using log-likelihood

Notifications You must be signed in to change notification settings

LucasLegendre/fitEvolPar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

fitEvolPar

Description

This function estimates the best fit for an evolutionary parameter (α, λ, or g) in a phylogenetic generalised least squares (PGLS) model, using log-likelihood.

Usage

fitEvolPar(dat, tre, mod=c("OU", "lambda","EB"))

Arguments

dat       a data frame containing the two variables (predictive and response) to include in a PGLS analysis

tre       a phylogenetic tree (object of class "phylo"); tre needs not be ultrametric

mod       the phylogenetic correlation structure (covariance matrix) for the evolutionary model of the PGLS

Details

This function is designed to provide the best estimate of the parameter of choice if optim fails to return its value when compiling it in a gls object. In such a case, the value for it needs to be fixed (fixed = TRUE), which requires an input for the parameter's best fit.

Function will stop if the data contains missing values and/or if the tips of the tree do not match the row names in the data frame. Data frame dat needs to have two columns: the predictive variable (x) on the left, and the response one (y) on the right.

Correlations structures defined by the user with mod can be: "OU"(Ornstein-Uhlenbeck – Martins and Hansen, 1997; Butler and King, 2004), "lambda" (Brownian Motion with a maximum likelihood estimate of Pagel's λ – Freckleton et al., 2002), or "EB" (Early Burst – Blomberg et al., 2003). PGLS models are fitted using gls in nlme with correlation structures from ape (see ?corClasses).

Value

A parameter estimate for the model of choice (α for "OU", Pagel's λ for "lambda", or g for "EB"). Value is comprised between 0 and 1 (0.1 and 1 for g), with one significant figure.

Author(s)

Lucas Legendre lucasjlegendre@gmail.com

Acknowledgements

This function was adapted from a piece of code written by Emmanuel Paradis on the R-sig-phylo mailing list (https://stat.ethz.ch/mailman/listinfo/r-sig-phylo).

References

Blomberg, S. P., Garland, T. and Ives, A. R. (2003) Testing for phylogenetic signal in comparative data: Behavioral traits are more labile. Evolution, 57, 717–745.

Butler, M. A. and King, A. A. (2004) Phylogenetic comparative analysis: A modeling approach for adaptive evolution. The American Naturalist, 164, 683–695.

Freckleton, R. P., Harvey, P. H. and Pagel, M. (2002) Phylogenetic analysis and comparative data: A test and review of evidence. The American Naturalist, 160, 712–726.

Martins, E. P. and Hansen, T. F. (1997) Phylogenies and the comparative method: a general approach to incorporating phylogenetic information into the analysis of interspecific data. The American Naturalist, 149, 646–667.

See Also

corClasses, gls

Examples

library(nlme)
library(ape)
library(evobiR)
library(phytools)

# Load the data
data(anole.data)
data(anoletree)

# Reorganize the data into 'dat'
dat<-cbind.data.frame(anole.data$SVL, anole.data$HL)
colnames(dat)<-c("SVL", "HL"); rownames(dat)<-rownames(anole.data)

# Estimate individual parameter for a lambda model
fitEvolPar(dat, anoletree, "lambda")

# Use in a 'gls' object with an OU model
reg<-gls(HL~SVL, anole.data, correlation=corMartins(fitEvolPar(dat, anoletree, "OU"), phy = anoletree, fixed = TRUE, form=~spp))
summary(reg)

About

Function to estimate evolutionary parameter in PGLS models using log-likelihood

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages