Computation

R Package lefko3

Package lefko3 is designed to provide a complete working environment to create and analyze matrix projection models (MPMs), including Leslie MPMs, Lefkovitch MPMs, historical stage-classified MPMs, integral projection models (IPMs), and age-by-stage MPMs, in both raw and function-based formats. It handles the entire workflow in MPM development, from formatting the demographic dataset, to building the life history model, to parameterizing vital rate models, to contructing the MPM, and finally to projection and analysis.

Package lefko3 works on R 3.6.3 or greater on all systems that support R, including Windows, MacOS, Linux, and Unix.

The project is hosted on CRAN and R-Forge. The most stable version of lefko3 is available for download through CRAN, and can be automatically downloaded with the install.packages() function in base R. The most recent development version is available through R-Forge here. Documentation is available here. Please also see our paper and cite our paper describing lefko3 in Methods in Ecology and Evolution.


Current stable version: 6.4.0 (Mar 2025). Available on CRAN.

New in this stable version: Function supplemental() now handles additive offsets to matrix elements. All matrix creation and projection functions are able to handle these offsets.

Current development version: 6.3.2.9012 (Jan 2025). Available on R-Forge.

New in this development version: New supplemental() functionality and some bug fixes..

Next stable version: 6.4.1 (mid 2025).

On the drawing board: Individual resampling functions. Fast linear model search function. Bootstrapping functions for vertical datasets. Adaptive dynamics projection and pairwise invasion analysis. Tests of reducibility and ergodicity. Complex IPMs with non-standard size functions. Demetrius entropy and Keyfitz entropy estimation.

lefko3: a gentle introduction: a free online book teaching the use of lefko3. The official html version is available through Bookdown on R Studio Connect, at this site. To go to specific chapter, use the following links:

Tutorial materials already packaged with lefko3:

  1. Tutorial on theory, methods, and concepts
  2. Tutorial example of raw historical and ahistorical MPM analysis using Lathyrus vernus
  3. Tutorial example of function-based historical and ahistorical MPM analysis using Cypripedium candidum
  4. Tutorial example of historical and ahistorical IPM analysis using Lathyrus vernus
  5. Tutorial example of ahistorical age x stage MPM analysis using Lathyrus vernus
  6. Tutorial example of deterministic and stochastic LTRE analysis, and MPM import, using the Anthyllis vulneraria example published in Davison et al. 2010

Please contact the lab for further details about workshops.

Installation notes: Package lefko3 is available in its stable format on CRAN and can be downloaded with all relevant binaries from there. However, some users may occasionally wish to download and install the package from source. For example, Mac users wishing to install the development version from R Forge will need to be able to install from source. Package lefko3 is unlike the typical R package in that it relies on core kernels written in C++ to power its functions. This means that installation from source generally requires the installation of some development tools in order for R to install from source properly. If you are a Linux user, then your version of R is already set up to install lefko3 from source. However, if you are a Mac or Windows user, then you will need to complete a few extra steps to install lefko3 successfully from source.

Users may occasionally have issues with R not automatically installing the required packages for lefko3 to function properly when installed. Please make sure to install the following packages manually, in that circumstance (install in the following order): Rcpp, RcppArmadillo, BH, Matrix, TMB, lme4, pscl, VGAM, glmmTMB, Rcompadre, popbio. We also recommend the packages pryr and BAMMtools, for use with our user manual lefko3: a gentle introduction.

Mac users: To set up your Mac to install lefko3 from source, please follow these steps:

  1. Download and install the latest Xcode from the Apple App Store. This is a very large program - over 10GB. It provides the compilers and interfaces that the Mac version of R relies on to compile code.
  2. Download and install Xcode Command Line Tools. To do so, please open the Mac terminal, and type "xcode-select --install". This may open a diaglog box asking you if you would like to install developer tools. If this happens, then please click "Yes" or "Install".
  3. Download and install the latest GNU Fortran Compiler, available here. Choose the most appropriate build given your architecture (pay special attention to the OS version, and to the type of microprocessor).
  4. Open the Mac terminal back up, and type "export PATH=$PATH:/usr/local/gfortran/bin". This command adds GNU Fortran to the command path, thus allowing R to use it.
  5. Congrats! You should now be able to install from source!

Windows users: To set up your PC to install lefko3 from source, please follow these steps:

  1. Download and install Rtools.
  2. Add Rtools to the command path. See the section on this in the Rtools download page.


Biology

Evolution of mycoheterotrophy

Evolutionary loss of photosynthesis

We are analyzing long-term demographic data and parameterizing evolutionary models to understand why so many plant species have lost photosynthesis and evolved to parasitize mycorrhizal fungi. Our work is both demographic and comparative, invloving matrix projection, adaptive dynamics, and phylogenetic analysis to understand these phenomena.


Individual history

Eco-evolutionary impacts of individual history

The events that occur in an individual's life can affect that individual in the long-term, and this impact can extend to long-term influences on population dynamics. For example, one of the greatest long-term impacts of individual history on mortality in herbaceous plants can come from high growth between years. We are studying the ecological and evolutionary dimensiomns of these impacts, and creating tools to study them.


Evolution of sprouting

Adaptive dynamics of sprouting

Why can so many photosynthetic plants live for years as rootstock with photosynthesizing? We address this question with a variety of evolutionary methods, including reconstructing trait evolution and game theoretical modeling. Our research has been featured in the news media, including on Nexus Media, Science Daily, or the Daily Mail.


Drivers of demography

Drivers of plant demography

Why do plant populations vary in demographic response to climatic variation? How does genetic composition interact with environment to determine population dynamics? We work with herbaceous perennials to answer these questions.


Evolution of senescence

Plant and fungal senescence

We generally believe all organisms will senesce if they live long enough, but empirical assessments and some theory suggest otherwise. What determines how senescence evolves across the Tree of Life?