Git Product home page Git Product logo

fitevolpar's Introduction

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 [email protected]

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)

fitevolpar's People

Contributors

lucaslegendre avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.