Rcontrast: R interface for contrast

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Rphylip.R


This function is an R interface for contrast in the PHYLIP package (Felsenstein 2013). contrast can be used to perform the among species phylogenetically independent contrasts method of Felsenstein (1985) and the within & among species method of Felsenstein (2008).

More information about the contrast program in PHYLIP can be found here http://evolution.genetics.washington.edu/phylip/doc/contrast.html.

Obviously, use of any of the functions of this package requires that PHYLIP (Felsenstein 1989, 2013) should first be installed. Instructions for installing PHYLIP can be found on the PHYLIP webpage: http://evolution.genetics.washington.edu/phylip.html.


Rcontrast(tree, X, path=NULL, ...)



object of class "phylo".


a matrix of continuous valued traits (in columns) with rownames containing species names. For one trait, X can be a matrix with one column or a vector with names(X) containing species names matching tree$tip.label. For within-species contrasts analysis, the matrix should contain repeating (identical) row names for conspecifics.


path to the executable containing contrast. If path = NULL, the R will search several commonly used directories for the correct executable file.


optional arguments to be passed to contrast. See details for more information.


Optional arguments include the following: quiet suppress some output to R console (defaults to quiet = FALSE); and cleanup remove PHYLIP input/output files after the analysis is completed (defaults to cleanup = TRUE).


If X contains one observation per species (say, the species mean), then Rcontrast returns a list with the following components: Contrasts, a matrix with all phylogenetically independent contrats; Covariance_matrix, a matrix containing the evolutionary variances (on diagonals) and covariances; Regressions, a matrix containing the pair-wise bivariate regression coefficients (columns on rows); Correlations, a correlation matrix of contrasts.

If X contains more than one sample per species, then Rcontrast returns a list with the following elements: VarA, the estimated among-species variance-covariance matrix; VarE, the estimated within-species (i.e., 'environmental') variance-covariance matrix; VarA.Regression, a matrix containing the pair-wise bivariate among-species regression coefficients (columns on rows); VarA.Correlations, a matrix with the among-species evolutionary correlations; VarE.Regressions, the pair-wise bivariate within-species regression coefficients; VarE.Correlations, the within-species correlations; nonVa.VarE, nonVa.VarE.Regressions, and nonVa.VarA.Correlations, estimates obtained when VarA is not included in the model; logLik and nonVa.logLik, log-likelihood when VarA is included (or not) in the model; k and nonVa.k the number of parameters estimated in each model; and P the p-value of a likelihood-ratio test of VarA, in which df = k - nonVa.k.


Liam J. Revell, Scott A. Chamberlain

Maintainer: Liam J. Revell <liam.revell@umb.edu>


Felsenstein, J. (1985) Phylogenies and the comparative method. American Naturalist, 125, 1-15.

Felsenstein, J. (1989) PHYLIP–Phylogeny Inference Package (Version 3.2). Cladistics, 5, 164-166.

Felsenstein, J. (2008) Comparative methods with sampling error and within-species variation: Contrasts revisited and revised. American Naturalist, 171, 713-725.

Felsenstein, J. (2013) PHYLIP (Phylogeny Inference Package) version 3.695. Distributed by the author. Department of Genome Sciences, University of Washington, Seattle.

See Also

pic, Rcontml, Rthreshml


## Not run: 
contrasts<-Rcontrast(tree = cotton$tree, X = cotton$data)

## End(Not run)

Rphylip documentation built on May 20, 2017, 12:43 a.m.

Search within the Rphylip package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.