Species coexistence in R
A patch of grassland or a hectare of forest holds many species that all want the same few things: light, water, nutrients, space. Simple competition theory says the best competitor should win and the rest should go, yet they persist side by side. Coexistence theory is the body of work that explains why, and it turns out to have several distinct answers. This page collects every tutorial on this site that builds one of those answers by hand in base R, from the classical competition models to the modern invasion-based framework.
Stabilising and equalising
Modern coexistence theory splits the problem cleanly. A stabilising mechanism is anything that makes a species grow faster when it is rare than when it is common, so that whichever competitor falls behind is pushed back up; niche differences are the classic source. A fitness difference is the average advantage one species holds regardless of frequency, and it works the other way, toward exclusion. Coexistence is not about having a large niche difference in absolute terms; it is about the stabilising difference being large enough to overcome the fitness difference between the particular species in question. That balance, not either quantity alone, is the verdict.
Enemies that punish being common
One of the oldest specific mechanisms is the idea that a species carries its own specialised enemies, the seed predators, herbivores and soil pathogens that attack it and not its neighbours. Those enemies build up wherever the species is abundant, so an individual does worst exactly where its own kind is common. This conspecific negative density dependence gives every species an advantage when rare, and scaled across a community it can turn competitive exclusion into a diverse forest. It is a leading explanation for why tropical forests hold so many tree species, though it is deceptively hard to measure without fooling yourself.
Two ways a changing world helps
A constant environment is unkind to coexistence, but a varying one can hold competitors together that a fixed one would separate. There are two routes. The storage effect works when species respond differently to good and bad years and can store the gains of a good year in a long-lived or dormant stage; a rare species then banks its private good years without paying the crowding cost a common species cannot avoid. Relative nonlinearity is subtler, working through differences in how curved each species’ response to competition is, and it can stabilise or destabilise depending on the details. Both are fluctuation-dependent: switch off the variability and they vanish.
When there is more than one answer
Sometimes the community has not one stable outcome but several, and which one you get depends on history rather than on who is the better competitor. When each species suppresses the other more than itself, whoever arrives first wins, and the same patch under identical conditions can settle into different states. Followed along a slowly changing driver, that structure produces tipping points and hysteresis: a sudden collapse that reversing the driver does not undo. These are not failures of coexistence theory but a different regime of it, and telling a genuine alternative stable state from a smooth response to the environment takes a manipulation, not a snapshot.
The test is an invasion
Every one of these answers is checked the same way. Push a species to low density, hold the others at their usual abundances, and ask whether it grows. If each competitor can invade a community of the others, none can be lost and coexistence is stable; this is mutual invasibility, and it is the common currency that lets the mechanisms above be compared and even added together. It is also where the difficulty lives, because a low-density growth rate is easy to define and hard to measure, and much of the craft of coexistence analysis is in earning that number rather than assuming it.
The tutorials
Competition and the coexistence question
- Annual plant competition models - fitting competition coefficients, and why an additive design cannot identify the intraspecific term.
- Niche and fitness differences - splitting a fitted pair into a stabilising niche difference and a fitness ratio, with the invasion criterion.
- Assumptions behind coexistence - why the coexistence verdict is an extrapolation beyond the data, and what it rests on.
- Checking a coexistence analysis - mutual invasibility, whether the design identifies self-limitation, and surviving a change of model.
Enemies and negative density dependence
- Janzen-Connell and tree diversity - how specialised natural enemies near parent trees turn exclusion into coexistence.
- Conspecific negative density dependence - measuring how a species survives worse among its own kind, and the condition for coexistence.
- Rare-species advantage and coexistence - negative frequency dependence as the coexistence logic, and the invasion criterion.
- Checking a CNDD analysis - the habitat confound, estimation bias, and enemies versus competition.
Coexistence in a fluctuating environment
- The storage effect and coexistence - how a variable environment plus buffered growth gives a rare species its advantage.
- Relative nonlinearity of competition - a second fluctuation-dependent mechanism, where curvature and variance change average growth.
- Partitioning the invasion growth rate - splitting a rare species’ growth into a fluctuation-free part and the storage effect.
- Checking a storage-effect analysis - the three ingredients, and why environmental variance alone is not coexistence.
More than one stable outcome
- Priority effects and alternative stable states - when strong mutual competition makes the winner depend on who arrives first.
- Basins of attraction - mapping which starting abundances lead to which state, and the separatrix between them.
- Hysteresis and tipping points - why a slow driver tips a system suddenly and why reversing it does not reverse the collapse.
- Checking for alternative stable states - why bimodality is not proof and why the evidence needs a perturbation.
Where this connects
- Biodiversity and ecosystem function in R shares the language of complementarity, a niche difference seen through what a mixture produces.
- Species diversity in R measures the diversity that these coexistence mechanisms are invoked to maintain.
- Population models in R builds the single-species dynamics that competition couples together.
- The Levins metapopulation model is coexistence written in space, with patches standing in for individuals.