Start here: ecological data analysis in R
This page is a reading order, not a feed. The tutorials below are grouped by the stage of a typical analysis, so you can follow a path instead of picking posts at random. Each section is roughly self-contained; jump to the stage you need, or read top to bottom.
If you are new to R for ecology, start with first steps and the foundations, then move to whichever data type you work with: community tables (diversity, ordination), counts and presence-absence (GLMs), grouped or repeated measurements (mixed models), or spatial layers (GIS).
If you would rather be told what to read next than choose, the course is one numbered route through the essentials, from a messy field sheet to a result you can defend. It uses tutorials from this page, in a fixed order, with a reason given for each position.
Topic pages
If you already know which subject you need, these pages take one topic on its own: what the methods do, where they break, and every tutorial on it in reading order. The rest of this page stays the route through the whole site.
- R for ecologists - getting field data into R and ready to analyse: reading, cleaning, reshaping, joining, and a first result.
- Species diversity in R - alpha indices, sampling effort and the unseen tail, and the three arithmetics of beta diversity.
- Ordination in R - NMDS, PCA, RDA and CCA, the tests that go with them, and the model-based alternative.
- Occupancy modelling in R - detection against occupancy, from single-season models to dynamic, multi-species and multi-scale versions.
- Capture-recapture in R - abundance, survival and density from marked animals, from closed populations to spatial models.
- Movement ecology in R - home ranges, paths, behavioural states, tag error, and step selection.
- Population models in R - matrices, integral projection models, and joining demographic data to counts.
- Species coexistence in R - niche and fitness differences, the storage effect, enemies, and alternative stable states.
- Ecological time series in R - autocorrelation, cycles, wavelets, empirical dynamic modelling and early warning signals.
- Causal inference in ecology with R - confounders, colliders, designs that identify, and the assumption you cannot test.
- Evolutionary game theory in R - the hawk-dove ESS, replicator dynamics, the routes to cooperation, spatial games, and drift in finite populations.
- Quantitative genetics in R - selection differentials and gradients, the breeder’s equation, the G matrix, and the Price equation.
- Population genetics in R - allele frequencies, F-statistics, effective size and the coalescent, built from scratch and checked against simulations
- Landscape connectivity in R - habitat pattern, cost surfaces and circuit theory, and the genetic data that tests whether a connectivity map means anything
- Conservation decisions in R - reserve selection, reintroduction and restoration, and the decision analysis that turns a model into a defensible choice
- Bayesian computation in R - Metropolis, Gibbs, Hamiltonian Monte Carlo, the Laplace approximation and ABC written by hand, with the diagnostics that read them
- Reproducible workflows in R - testing, debugging, profiling, dependency pinning, pipelines, packaging and version control, each scored against the failure it prevents
- Data provenance checks in R - testing a dataset against the record it came from: the frame, the protocol, the recording grid and the species list, with the cost of each gap measured
First steps: getting data into R
Before any method, get your field data into R, cleaned and in the right shape. Start here if you are new to R for ecology.
- Setting up R and RStudio for ecology - RStudio projects instead of setwd, install once and library every session, and the hidden-state bug that silently changes your results.
- Reading field data into R - read.csv, na.strings, and why a blank cell is not a zero.
- What a CSV loses: archiving an R analysis - the deposited file round-trips the numbers and drops the level ordering, so the same script reports the opposite trend.
- Wide and long: reshaping species data - pivot between a species matrix and one-row-per-record with tidyr.
- Cleaning species names before you count - trimws, tolower and a lookup table, and why fuzzy matching misleads.
- Dates and times in ecological data - where the silent NA comes from, the day and month transposition that never warns, and what the calendar gets wrong.
- Text and regular expressions in R - pulling site codes and measurements out of free-text field notes, and the precision and recall of the pattern that does it.
- Your first ggplot: data, aes and geom - the three pieces of a plot and the mapping-versus-setting error.
- Summarising ecological data by group - group_by and summarise, and why the mean of proportions is not the pooled proportion.
- Joining ecological tables without losing zeros - why an inner join drops absent sites and a left join keeps the zeros.
- From a field sheet to your first analysis - a worked pipeline from a messy sheet to a first diversity result.
Foundations
Get the basics of estimation and a reproducible setup in place before modelling anything. The estimation thread does not stop here: it picks up again further down the page, in Bootstrap and resampling inference, Multiple testing and error rates, and the Common pitfalls list at the end.
- Standard errors and confidence intervals - what SE actually measures, t-based CIs for a mean, and why coverage matters.
- Bootstrap confidence intervals - a first bootstrap: one statistic, one interval, ahead of the dedicated series in Bootstrap and resampling inference.
- A reproducible statistical workflow - where to put set.seed, version pinning with sessionInfo, relative paths, and clean-session rendering.
Writing analysis code you can trust
The errors that cost most are the ones that run to the end and return a plausible wrong number. These four measure what each habit catches and what it misses.
- Testing your analysis code - a test runner in twenty lines of base R, and which kind of test earns its lines against thirty-odd deliberate bugs.
- Debugging and defensive R code - silent recycling, the factor trap, and what stopifnot catches that a handler cannot.
- Speeding up your analysis code - measure before you rewrite, why vectorising pays a constant and a hash lookup pays more and more, and when the slow readable version is right.
- Checking an analysis script - does it run from a clean session, give the same answer twice, and report the numbers it actually computed.
Keeping a project reproducible
The result has to survive a new laptop, a package update and six months. Each of these is written by hand in base R so you can see what the tool is doing for you.
- Pinning package versions with renv - a lockfile is a claim, and a changed default that alters the answer with no error at all.
- Building an analysis pipeline with targets - a pipeline is an invalidation graph, and tracking it in your head is cheaper and wrong.
- Turning your code into an R package - the cure for copy-paste, measured on three analyses that quietly drifted apart.
- Git for ecologists - which state of the code produced the figure in the manuscript, and what it takes to get it back.
Diversity and community description
Summarise what is in your samples: richness, evenness, and the structure of an assemblage.
- Diversity indices in R - richness, Shannon and Simpson from a site-by-species matrix.
- When not to use Shannon - why one number hides richness and evenness, and what Hill numbers give you instead.
- Rarefaction and accumulation curves - comparing richness fairly across uneven sampling effort.
- Species abundance distributions - rank-abundance and fitting SAD models.
- Species-area relationships - fitting the power law and the logarithmic model, and reading the exponent z.
- Functional diversity - diversity from continuous and categorical traits.
- Checking a functional diversity analysis - the number of trait ordination axes you keep reorders the communities, and the best one changes in seven cases out of ten.
- Beta diversity partitioning - splitting turnover from nestedness in the Baselga framework.
- Additive diversity partitioning - splitting gamma into alpha and beta additively, and where Hill numbers matter.
- Nestedness, NODF and null models - measuring nested structure, and how the null model decides the verdict.
- Distance decay of community similarity - how shared species fall off with distance, and why the test needs a Mantel permutation.
- Elements of metacommunity structure - coherence, turnover and boundary clumping coded by hand, and the one statistic in the decision key that is not tested against a null.
Diversity estimation
Go beyond what you observed: the unseen-species problem, and estimating richness and diversity from an incomplete sample.
- Estimating species richness beyond your sample - Chao1, ACE and the jackknife estimators as lower bounds on true richness.
- Coverage-based rarefaction and extrapolation - comparing samples at equal coverage rather than equal size, and extrapolating.
- Estimating diversity with Hill numbers - bias-corrected Hill numbers, and how the correction depends on the order q.
- Checking a diversity estimate - coverage deficit, singleton sensitivity, and honest confidence intervals for the estimate.
Beta diversity
How much composition changes between sites is one number with three different arithmetics behind it, and they do not agree.
- Multiplicative beta diversity with Hill numbers - why the naive average alpha gives an impossible beta below one, and the exact identity linking Hill beta to the Sorensen index.
- Zeta diversity in R: beyond pairwise turnover - the multi-site question pairwise dissimilarity cannot ask, and why a power-law decline is not evidence of niche assembly.
- Beta diversity as variance: LCBD and SCBD - a beta diversity number per site and per species, the bound nobody quotes, and two measured traps in reading LCBD.
- Checking a beta diversity analysis - sampling effort, the choice of metric, and the site set, each shown flipping the verdict on data with a known answer.
Neutral theory
What an assemblage looks like when nothing separates the species, and what it takes to test that against the alternative.
- Neutral theory in R: theta and the Ewens formula - Hubbell’s theta from an abundance vector, and the measured fact that the fit reads only richness and sample size.
- Dispersal limitation: fitting theta and m in R - Etienne’s sampling formula in base R, and what fitting Ewens to a dispersal-limited plot costs.
- The exact Ewens test: is your SAD neutral? - condition on richness and the null loses its free parameter; measured power against three niche models.
- Checking a neutral model fit - interval calibration, out-of-sample richness prediction, and the blind spot two shape-based checks share.
Ordination and multivariate structure
Explore gradients and group differences in multivariate community data.
- Choosing a dissimilarity index - the decision that sits underneath every ordination and PERMANOVA.
- NMDS ordination - non-metric ordination of community composition.
- Checking an NMDS stress value - what a stress value means once sample size is taken into account.
- PCA on environmental data - ordination for abiotic variables, with standardisation.
- Constrained ordination with dbRDA - relating composition to measured predictors.
- capscale vs dbRDA - the two distance-based constrained ordinations in vegan.
- RDA vs CCA and gradient length - choosing a linear or unimodal method from DCA gradient length.
- Variance partitioning - how much variation environment and space each explain.
- Non-linear gradients with ordisurf - a smooth GAM surface where a straight arrow would mislead.
- envfit and PERMANOVA - fitting vectors and testing group differences with adonis2 and betadisper.
- Pairwise PERMANOVA - which groups differ after a significant omnibus test.
- Common PERMANOVA mistakes - dispersion vs location, permutation structure, and unbalanced designs.
- Hierarchical clustering and dendrograms - grouping sites from a Bray-Curtis distance.
- Checking a community classification - testing clusters on the matrix that produced them, and a null that repeats the search.
- Mantel tests - correlating two distance matrices.
- Comparing two ordinations with Procrustes - rotating one configuration onto another before comparing it, a permutation test for what is left over, and the site residuals a single number hides.
- Indicator species analysis - which species characterise which groups.
- What SIMPER actually ranks - why a variable species can top the contribution table.
- Co-occurrence null models - testing whether species associations differ from random.
Ecological networks and species interactions
Who interacts with whom, as a bipartite web. Every structural number here needs a null model before it means anything.
- Bipartite network metrics from scratch - connectance, generality and vulnerability, and the standardised specialisation indices H2’ and d’.
- Modularity in ecological networks - Barber modularity by label propagation, and the c-z roles that mark connectors and hubs.
- Null models for interaction networks - one NODF against three nulls, where the fixed-fixed null reverses the verdict.
- Checking a network analysis - how sampling effort moves every metric, and why a forbidden link looks like an unsampled one.
Food web structure and stability
Store a food web as a matrix, measure it, and ask how much of what you report is the web itself and how much is the model or the sampling.
- Food web structure: connectance and trophic level - store a food web as a matrix and measure connectance and trophic level; why the trophic level you report is a modelling choice, not a fixed number.
- The niche model of food webs - generate webs from one feeding axis and compare to the cascade and random models; a random graph at real connectance usually leaves no basal species.
- Stability and complexity in food webs - May’s stability threshold in R, and how predator-prey sign structure moves the boundary far to the stable side.
- Checking a food web analysis - three checks: sampling effort biases connectance, the null model decides significance, and the stability verdict depends on assumed self-regulation.
Linear models and classical tests
The tests most ecologists meet first are one model wearing different names. Fitting that model directly puts the assumptions back where you can see them.
- Classical tests as linear models - the t-test and ANOVA seen as one framework.
- What a rank test actually tests - the Wilcoxon null is about whole distributions, so unequal spread makes it reject when the medians agree.
- Contrasts and post-hoc tests - which groups differ after a significant ANOVA.
- Term order in unbalanced factorial ANOVA - why A times B and B times A give different p-values for the same fit once the cells are uneven, and what a type three table tests under R’s default contrasts.
GLMs: families, diagnostics and interpretation
Counts, proportions and presence-absence want a family and a link, not a transformed response. This section runs the whole cycle: choose the family, find out whether it fits, and turn coefficients into something reportable.
- Logistic regression for presence-absence - binomial GLMs with a logit link.
- GLMs for count data - why not to log-transform counts, and what to fit instead.
- Zero-inflated count models - ZINB and hurdle models for excess zeros.
- Parasite burdens truncated by host death - when the heaviest infections die before you sample them, the mean comes out low while the fitted aggregation barely moves.
- Offsets for rates and densities - modelling per-effort rates correctly in a Poisson GLM.
- GAM species response curves - smooth response shapes with mgcv.
- GLM residual diagnostics - why Pearson and deviance residuals mislead, and what to check.
- Dispersion checks when the counts are small - residual deviance over degrees of freedom flags correctly specified models at ecological count sizes, while the Pearson statistic beside it holds its rate.
- Predicting on the response scale - building CIs on the link scale, then back-transforming.
- Interaction terms in GLMs - reading an interaction through predictions, not coefficients.
- Contrasts after a GLM - marginal means and pairwise contrasts with multiplicity correction.
Inference traps
None of these depend on which family you picked. They are the ways a correctly fitted model still yields a wrong conclusion, and each one is measured here rather than asserted.
- Comparing significance is not a test - significant in one group and not in the other is not a comparison, and the interaction test is the procedure that is.
- Collinearity and VIF - how correlated predictors inflate standard errors.
- Residuals as a variable: the two-step trap - carrying the residual of one predictor into a second model gets its uncertainty wrong, and which way depends on where the first slope came from.
- Power analysis by simulation - estimating power when there is no closed-form formula.
- Testing for no effect: equivalence tests in R - two one-sided tests against a bound you choose in advance, and the four verdicts a study can reach.
- Robust regression for ecological outliers - leverage against influence, how much contamination each estimator survives before its answer is worthless, and what the insurance costs on clean data.
Model selection and multi-model inference
Start with what AIC measures, then with what to do when no single model wins: the ranking itself carries uncertainty, so share the evidence across the candidate set instead of crowning a winner.
- Model selection and AIC - what AIC measures and how to use it.
- Akaike weights and evidence ratios - turn AIC differences into weights that sum to one, read evidence ratios between models, and score variable importance with its limits stated.
- Model-averaged predictions - combine predictions in proportion to their weights, and build the unconditional interval that covers correctly because it absorbs selection uncertainty.
- Model-averaged coefficients: a caution - why averaging coefficients across models blends quantities that mean different things, and how collinearity makes the averaged value drift.
- AIC with missing values: the silent row drop - candidates fitted to different rows are not comparable, and the ranking comes out as the ranking of the gaps.
- Checking a multi-model analysis - three checks: selection bias and the winner’s curse, dependence on the candidate set, and what happens when the truth is not in the set.
Finite mixture models
A histogram with bumps in it, the EM algorithm that separates them, and the harder question of whether the bumps are there at all.
- Fitting a mixture of normals in R - EM by hand on a length-frequency sample, soft classification, and the degenerate solution.
- How many components in a mixture? - why the likelihood ratio test has no chi-squared null, and what the information criteria do instead.
- When a mixture is really skewness - a two-component fit to data with no components, and what actually tells the two apart.
- Checking a mixture model - label switching against genuine local optima, classification uncertainty, and a predictive check that can fail.
Nonlinear regression
Fit a response that is nonlinear in its parameters, and read the honest limits of the fit.
- Nonlinear regression in R with nls - fitting a functional response directly, and why linearising it biases the parameters.
- Fitting growth curves with nls - the von Bertalanffy curve, and the trade-off between the asymptote and the growth rate.
- Starting values and identifiability in nls - when a fit fails to converge, and when two parameters cannot be separated.
- Checking a nonlinear model - weighted fits for non-constant variance, and why the Wald interval can be over-optimistic.
Thresholds and change points
Test for a breakpoint or regime shift, and resist reading one into a smooth response.
- Segmented regression for a breakpoint - fitting a broken-stick model and a confidence interval for the breakpoint.
- Testing for an ecological threshold - why the naive test for a change point rejects far too often, and what to do instead.
- Threshold regression with a GLM - profiling a Poisson deviance for a regime shift in count data.
- Checking a threshold model - residual curvature, coverage, and sensitivity to the assumed shape.
Quantile and distributional regression
Model the quantiles or the spread, not just the mean, when the mean is not the ecology.
- Quantile regression in ecology - modelling the quantiles rather than the mean, with the check-loss from scratch.
- Heteroscedasticity and limiting factors - the Cade-Noon wedge, and why an upper quantile recovers a ceiling slope.
- Distributional regression with location and scale - modelling the mean and the spread together, and calibrating prediction intervals.
- Checking a quantile regression - quantile crossing, rearrangement, and where the tail interval widens.
Generalised additive models
Let the data set the smoothness through a penalty, and know what the basis can and cannot do.
- Penalised regression splines from scratch - a B-spline basis with a difference penalty, and effective degrees of freedom.
- Choosing the basis dimension k in mgcv - why k is a ceiling on wiggliness, not the fit itself.
- Concurvity in additive models - the smooth analogue of collinearity, invisible to the VIF.
- Checking a generalised additive model - residual autocorrelation, and pre-checking the basis and concurvity.
Regularisation
Trade a little bias for less variance with a penalty, and see why the naive interval no longer holds.
- Ridge regression for collinear predictors - the L2 penalty as a bias-variance trade, shrinking correlated predictors together.
- Lasso and variable selection - the L1 penalty by coordinate descent, and why the selected set is unstable.
- Elastic net and cross-validation - keeping a correlated group together, at a cost in sparsity.
- Checking a penalised regression - why the naive interval is invalid, and how a sample split restores coverage.
Tree-based and ensemble methods
Predict well with trees and ensembles, and keep prediction separate from explanation.
- Regression trees and CART, by hand - recursive binary splitting, cost-complexity pruning, and how a full tree overfits.
- Bagging and random forests, by hand - averaging down variance, and when decorrelation does and does not help.
- Boosted regression trees, by hand - fitting the residuals in sequence, and the learning-rate and tree-count trade-off.
- Checking a tree ensemble - why importance is not an effect, and why out-of-bag error is optimistic under spatial structure.
Flexible smoothing and predictive uncertainty
Flexible smoothers and honest prediction intervals, and why a reported interval is only a promise until you check it.
- Gaussian process regression from scratch - an RBF kernel by Cholesky solve, and why the length-scale is only weakly identified.
- Local regression from scratch - the smoothing matrix, a leave-one-out bandwidth, and the bias a variance-only band ignores.
- Conformal prediction intervals from scratch - distribution-free marginal coverage, and where it stops being conditional.
- Checking a predictive model: calibration and coverage - coverage on held-out data, the PIT histogram, and the reliability diagram.
Model-based multivariate analysis
Per-species GLMs and community resampling separate what distance-based methods confound.
- Model-based multivariate abundance - a GLM per species instead of a distance matrix, and why the mean-variance link matters.
- Model-based unconstrained ordination - a latent-variable ordination that respects the count distribution.
- Fourth-corner trait-environment analysis - linking traits to environment, and why the naive site permutation rejects too often.
- Checking a model-based multivariate model - Dunn-Smyth residuals, and the assumptions the method still rests on.
Traits and the environment
Traits, sites and environment meet in one cross-table. These take it apart, from a single plot average up to the two ordinations built on the same table.
- Community weighted means in R - the plot level trait average, and the exact identity that links it to the fourth corner statistic.
- Intraspecific trait variability in R - splitting a trait gradient into a fixed part and a within species part, and when the percentages stop meaning anything.
- RLQ analysis in R: traits, sites and environment - the exact co-inertia decomposition, and why a redundant environmental proxy inflates the result by 86 per cent without adding information.
- Double constrained correspondence analysis in R - the correlation-maximising partner of RLQ, the proxy problem it fixes, and the correlation it manufactures from noise instead.
- Checking a trait environment analysis - the two permutation nulls, why each one alone rejects far too often, and why more sites make it worse.
Bounded and ordinal responses
Responses on the unit interval, ordered classes, and biomass with zeros, each modelled on its own scale.
- Beta regression for proportion and cover data - a logit link for a bounded continuous response, without squashing it into a normal.
- Ordinal regression for ordered cover classes - proportional odds for Braun-Blanquet classes, respecting the ordering.
- Tweedie regression for biomass and cover with zeros - one process for a continuous response with a spike at zero.
- Checking a bounded-response model - why Pearson and deviance residuals mislead off the normal family, and the randomised quantile residual.
Dose-response and ecotoxicology
Turning a concentration series into a number a regulator can act on, and finding out where that number actually comes from.
- Dose-response curves and the LC50 - the LC50 is fitted rather than measured: three link functions agree there and disagree by a multiple at the LC1, where there is no data to hold them together.
- Confidence intervals for effective doses - delta, Fieller and profile intervals scored on coverage and on sidedness, and the design choice that halves the LC10 interval at no cost in animals.
- Hormesis and non-monotonic responses - a monotonic model fitted to stimulated data reads the low-dose end wrong, and the test for hormesis passes on designs that never observe any stimulation.
- Checking a dose-response analysis - control mortality, vessel-level overdispersion, extrapolation below the lowest tested dose, and nominal against measured concentration.
Areal and lattice spatial models
On lattice data the question is not whether to model space but how, and every choice competes with a plain spatial covariance.
- Spatial lag and spatial error models (SAR) - the lag model as a spillover process, and the error model as a nuisance.
- Conditional autoregressive (CAR) models - areal dependence from local conditional distributions, and the symmetric-weight trap.
- Moran eigenvector spatial filtering - a GLM-compatible filter, and why it only partially controls the confounding.
- Geographically weighted regression in R - a coefficient map is drawn at a bandwidth you chose, a narrow one invents sign reversals on data with no spatial variation, and a coordinate permutation tests the claim the map is making.
- Checking a spatial regression - lag versus error, and how a spatial term can steal a real effect.
Time series analysis
Time-series tools mislead easily, so each one comes with an honest limit on what it can prove.
- Temporal autocorrelation and effective sample size - why dependence shrinks the independent information, and the spurious regression it invites.
- Fitting ARIMA models to ecological time series - order selection from the PACF, forecasting, and the cost of over-differencing.
- Spectral analysis of population cycles - the periodogram, smoothing, aliasing, and a red-noise null.
- Checking a time series model - residual whitening, prewhitening a cross-correlation, and why every check only falsifies.
Wavelets: cycles that come and go
A periodogram averages over the whole record, so it cannot tell you when a cycle was running. A wavelet transform keeps the time axis, at the price of a null model that is harder to get right.
- Wavelet analysis of population cycles - the Morlet transform by hand, and why a periodogram cannot tell you when.
- Wavelet significance and the red noise null - a white noise null flags a quarter of the map; test patches, not pixels.
- Wavelet coherence and phase - do two species cycle together, and which one leads.
- Checking a wavelet analysis - the scale bias, an event posing as a cycle, and the resolution knob.
Early warning signals and critical transitions
Rising autocorrelation and variance before a tipping point are real, but a rising indicator is a hypothesis, not a forecast.
- Early warning signals and critical slowing - lag-1 autocorrelation and variance as a fold bifurcation approaches.
- Detrending and bandwidth in early warning signals - how the analyst’s choices can flip the verdict.
- Spatial early warning signals - variance and Moran’s I in space, and why the pattern has other causes.
- Checking early warning signals - a surrogate null for the Kendall trend, and the false alarms of the naive test.
Empirical dynamic modelling
Rebuild the attractor from one series and test causality without a linear model. The evidence is convergence, not correlation.
- Simplex projection and delay embedding - Takens embedding and nearest-neighbour forecasting, and what separates chaos from noise with the same autocorrelation.
- The S-map and state-dependent dynamics - a nonlinearity test that is one model with one knob, and the interaction coefficients it returns.
- Convergent cross mapping in ecology - causality read from the driven species’ history, and why the direction looks backwards at first.
- Checking an empirical dynamic model - series length, a shared driver, and the synchrony that defeats the test.
MAR(1) community dynamics
A linear autoregressive model for a whole community, and the stability metrics that inherit every error the fit makes.
- Fitting a MAR(1) model to community time series - conditional least squares in three lines, and what a per-species AR(1) actually estimates.
- Interaction strengths from community time series - the diagonal bias that makes density dependence look stronger than it is.
- Community stability from a MAR(1) model - return rates, reactivity, and how to read the determinant index with care.
- Checking a MAR(1) model - how observation error makes a community look stable while every residual check stays silent.
Evaluating ecological forecasts
A forecast is a distribution, not a number. Score the whole distribution, then ask what the score is being compared against.
- Scoring ecological forecasts - why reducing a forecast to its mean and grading it with RMSE throws away the forecast, and what makes a scoring rule proper.
- The CRPS and the Brier score - the Brier score for presence and absence, the CRPS for abundance or a date, and the identity that shows they are one idea at two resolutions.
- Forecast skill and the baseline - a raw score means nothing on its own; the same forecast can look skilful or worthless depending on the reference you pick.
- Checking a forecast evaluation - three checks: coverage on its own rewards a wide forecast, sharpness counts only after calibration, and a small test set cannot separate two forecasts.
Predictive model hygiene
A fitted classifier is only useful once someone acts on it, and the steps between a fitted probability and a management decision are where most of the damage happens.
- Class imbalance in species presence models - what limits a rare-species model is the number of presences rather than the ratio, and downsampling moves the intercept by an amount you can write down.
- Calibrating predicted probabilities in R - reliability diagrams with an honest null band, the Murphy decomposition of the Brier score, and Platt scaling and isotonic regression written out.
- Data leakage in ecological model validation - four routes by which information crosses into the training fold, each with its measured optimism, including screening on the full dataset and splitting grouped rows.
- Choosing a decision threshold from costs - the cost-optimal threshold, the cost ratios that popular default rules imply without saying so, and decision curves against treating every site.
Bootstrap and resampling inference
Resampling is a tool, not a guarantee, and each variant fails in its own way.
- The nonparametric bootstrap - percentile, basic, normal and BCa intervals, and why only BCa handles skew correctly.
- The parametric bootstrap - simulating from the model for a boundary test the naive chi-squared gets wrong.
- Bootstrapping dependent data - resampling the unit of dependence with block and cluster bootstraps.
- Permutation tests from scratch - the complete enumeration, the floor a Monte Carlo p value cannot report below, and the studentised statistic that keeps its level under unequal variance.
- Checking a bootstrap - where a non-smooth statistic breaks, and why more data does not always fix it.
Extreme value analysis
Model the rare and the extreme: block maxima, threshold exceedances, and honest return levels for the tail of a distribution.
- Block maxima and the GEV distribution - fitting the generalised extreme value distribution to annual or seasonal maxima.
- Peaks over threshold and the GPD - the generalised Pareto distribution for exceedances, and how it uses the same tail more efficiently.
- Return levels and uncertainty - the level exceeded once every m years, with delta and profile-likelihood intervals.
- Tail dependence and joint extremes - a correlation measured in the middle of the distribution says nothing about the corners, and a Gaussian copula quietly sends the chance of a simultaneous failure to zero.
- Checking an extreme value model - where a return level is an honestly labelled guess, and how coverage degrades far into the tail.
Circular and directional statistics
Summarise angles and times of day: directions have no arithmetic mean, and the choice of test decides the verdict.
- Circular data and the von Mises distribution - the mean direction, resultant length, and why concentration is biased upward in small samples.
- Testing for circular uniformity - the Rayleigh test and why it is blind to axial, two-way patterns.
- Activity patterns and temporal overlap - the coefficient of overlap for camera-trap activity, and its upward bias.
- Comparing two groups of angles - two-sample tests of mean direction, and the false positive rate when the groups differ in scatter.
- Checking a circular analysis - how modality, test choice and bandwidth shape the number you report.
Phylogenetic and comparative methods
Account for shared ancestry when species are the data points, and measure phylogenetic pattern in traits.
- Phylogenetic diversity with picante - Faith PD and mean pairwise distance from a tree and a community table.
- Phylogenetic signal: Blomberg’s K and Pagel’s lambda - measuring how strongly a trait tracks the phylogeny.
- Independent contrasts: Felsenstein’s method - the original correction for non-independence among related species.
- Phylogenetic generalised least squares - regression with a phylogenetic correlation structure in the residuals.
- Ancestral state reconstruction - inferring trait values at the internal nodes of a tree.
Community phylogenetics
Bring the tree into the community table: is an assemblage more closely related than chance, and what is chance here.
- Phylogenetic community structure: NRI and NTI in R - standardised effect sizes for MPD and MNTD, and why the raw metrics cannot be compared across sites.
- Null models for phylogenetic community structure - the seven picante null models are two questions plus a choice of pool, and the choice is the hypothesis.
- Phylogenetic beta diversity: UniFrac and PhyloSor - branch length accounting between communities, and the exact identity linking the two metrics.
- Checking a community phylogenetics analysis - sweep the pool, calibrate the pipeline on null data, break the branch lengths.
Spatial data and GIS
Get occurrence records in and cleaned, then work with coordinates, rasters and the link between QGIS and R.
- Cleaning GBIF and iNaturalist records - dropping bad coordinates, duplicates and imprecise records before any mapping.
- Richness mapping with sf - spatial vector work and mapping in R.
- Raster basics with terra - raster structure and map algebra.
- LiDAR height normalisation on slopes - a cell minimum invents canopy height on a slope, sparse ground returns under closed canopy push the ground surface up, and the two errors have opposite sign.
- QGIS to R spatial join - a hybrid workflow between the QGIS GUI and sf.
- Spatial autocorrelation and Moran’s I - testing for spatial dependence with spdep.
- Kriging and spatial interpolation - continuous surfaces from scattered point samples.
- The variogram and the GP kernel - the term by term dictionary between geostatistics and Gaussian processes, and the one place the two estimators part company.
- Stream networks and tail-up covariance - interpolating along running water, where the Gaussian covariance stops being a valid one and a tail-up model is built from a moving average so that it cannot fail.
Satellite time series
A raster stack of dates is a set of time series stored in a map’s shape. These four build the cube, fit a seasonal curve to every pixel, deal with the cloud, and audit the covariate that comes out the other end.
- NDVI time series from a raster stack - the layer axis rather than the map, the recycling trap that silently returns hundreds of layers, and why the raw date of peak greenness is worse than a fitted one.
- Harmonic regression on a seasonal raster - amplitude and phase per pixel from a linear model, how many harmonics to keep, and the phase branch cut that makes averaging peak dates as numbers wrong.
- Filling cloud gaps in a satellite series - cloud is contiguous and seasonal rather than random, the ranking of fillers changes with the quantity you want, and the observations that pass the mask do more damage than the ones it removes.
- Checking a remote sensing covariate - alignment, extraction rule, grain, timing and the fact that the covariate is an estimate the model treats as known.
Species distribution modelling
Predict where a species can occur from occurrence records and environmental layers.
- Species distribution modelling with GLM - a presence-background model built on logistic regression.
- Pseudo-absence and background points - choosing the absences an SDM never actually observes.
- Evaluating species distribution models - AUC, threshold choice, and what they do and do not tell you.
- Spatial cross-validation for SDMs - honest performance when test points sit beside training points.
Presence-only distribution models
Most occurrence data are presence-only: records of where somebody saw the species, with no matching record of where nobody did. MaxEnt is the usual tool, and it is a penalised Poisson point process wearing a different name. These four tutorials build it from scratch, so the settings stop being folklore.
- MaxEnt as a Poisson point process - the point process likelihood, the count GLM, the Gibbs solution and weighted logistic regression are one model, and only the level differs.
- Regularisation and features in MaxEnt - hinge and threshold features built by hand, the L1 penalty that keeps them in check, and the regularisation path measured against held-out records.
- Sampling bias in presence-only models - four remedies scored against each other, including the prediction step people forget and the spatial thinning that introduces a bias of its own.
- Checking a presence-only model - clamping and extrapolation, the four output transforms, why AUC has a ceiling below one, and why a record split flatters the model.
Macroecological patterns
Patterns that only appear once many species are on one graph, and the measurement decisions that produce most of what you see.
- The abundance-occupancy relationship - occupancy is a censored measure of abundance, so a strong positive relationship appears with no biology at all in the generating model, and the scatter around it reads out spatial aggregation.
- Range size distributions - the right skew comes out of almost any multiplicative process, and grain and record count move the small-range tail further than anything ecological in the data.
- Checking a macroecological pattern - the shared denominator, the random-placement null, species that are not independent points, and a slope that moves with grain and extent.
Niche overlap between species
Put a number on how far two species share their environment, test it against a null, and see how much of that number belongs to the landscape rather than the species.
- Niche overlap: Schoener’s D and Warren’s I - the two density-comparison metrics behind ENMTools and ecospat, built from first principles, and why I sits above D for the same pair.
- Niche equivalency and similarity tests - two permutation tests with two different null hypotheses, and why a rejected equivalency test is not evidence of ecological difference.
- Niche overlap and the background - hold both species fixed, change only what climates the region contains, and watch the measured overlap slide; plus the correction and its price.
- Checking a niche comparison - three checks: the smoothing bandwidth moves the answer more than sampling does, low overlap can be geography, and the test can disagree with itself.
Detection and occupancy
Presence data are incomplete because species get missed. These models separate detection from occupancy.
- Imperfect detection and occupancy bias - why raw presence-absence underestimates where a species lives.
- Fitting single-season occupancy models - occupancy and detection from repeat visits to fixed sites.
- Occupancy and detection covariates - letting both occupancy and detection depend on predictors.
- How many visits? Occupancy survey design - the sites-versus-visits trade-off before you collect data.
- What a detection time is worth - what ticking boxes throws away against a full record of encounter times, from the exact Fisher information.
Dynamic occupancy
Occupancy across several seasons, where sites are colonised and go locally extinct, and detection is still imperfect.
- Dynamic occupancy: colonisation and extinction - the multi-season model, and why naive turnover overstates extinction.
- Covariates in dynamic occupancy models - letting colonisation, extinction and detection depend on predictors.
- Occupancy turnover and equilibrium - derived turnover, equilibrium occupancy, and the transient-trend trap.
- Checking a dynamic occupancy model - a bootstrap goodness-of-fit test for hidden detection heterogeneity.
Occupancy variants
Three models that promise more than occupancy from the same detection table, each resting on an assumption the table cannot test.
- The Royle-Nichols model - abundance from bare detections, and the heterogeneity slot that carries the label.
- Two-species occupancy and interactions - the Rota model, and the shared gradient that reports an interaction where there is none.
- False positives in occupancy models - misidentification at 5 per cent, a 5.8-fold bias, and an exact label switch.
- Checking an occupancy variant - why the cleanest fit of all four worlds comes from the wrong model.
eDNA and molecular detection
A water sample is a detection method with its own hierarchy: the species has to be at the site, its DNA has to be in the bottle, and the PCR replicate has to amplify. These add the laboratory layer to the occupancy models above, and take seriously the two errors it brings.
- Three-level occupancy models for eDNA - site occupancy, sample availability and replicate detection in one likelihood, and what pooling the levels costs.
- False positives in eDNA surveys - contamination as a replicate-level mixture, why forty replicates make it likely, and what negative controls buy.
- Sampling design for eDNA surveys - sites against samples against replicates under a budget, with the unit costs written down.
- Checking an eDNA occupancy analysis - detection heterogeneity, predictive checks, transported DNA, and pinning the contamination rate.
Acoustic monitoring
An autonomous recorder and a species recogniser turn a field season into a table of timestamped detections with confidence scores attached. That table is not a table of counts, and the difference matters before any model is fitted.
- Automated acoustic detections as data - why a detection count is affine rather than proportional to calling activity, and what the false-trigger floor does to a ratio between two sites.
- Score thresholds and precision in bioacoustics - the confusion matrix by hand, why AUC survives a change of prevalence and precision does not, and estimating precision from a score-stratified validation set.
- Call rates and density from acoustic surveys - cue counting from first principles, and the variance decomposition that says which component more recording effort cannot improve.
- Checking an acoustic monitoring analysis - bout structure and interval coverage, threshold transfer between sites, what duty cycling costs, and how large a validation set has to be.
Abundance and density estimation
Go beyond presence to count: estimate abundance and density from unmarked animals, while correcting for the individuals nobody saw.
- Removal and depletion sampling - estimating a closed population from declining catches.
- N-mixture models for abundance - abundance from repeated counts without marking individuals.
- N-mixture reliability and the detection trade-off - the three ways an N-mixture abundance estimate can be unreliable without the count warning you.
- Checking an N-mixture model - goodness of fit, residuals and K-sensitivity, and why passing is necessary but not sufficient.
Distance sampling extensions
The base method first, then covariates, points instead of lines, and a hierarchical version. Each extension moves the single number the density estimator reads off the curve at zero.
- Distance sampling for density - detection that falls off with distance along a transect.
- Covariates in the detection function - pooling keeps the total roughly right and reverses the comparison between strata.
- Point transect distance sampling - the estimator reads a slope, not a height, which is why the same wrong key function costs more.
- Hierarchical distance sampling - one visit with distances against three visits of counts, and the bet that decides it.
- Density surface models for distance sampling - a detection function, a spatial GAM on segments, and the variance term that turns a nominal 95 per cent interval into an 83 per cent one.
- Checking a distance sampling model - a fit test that passes surveys 12 per cent wrong, and the assumption that leaves no trace at all.
Camera trap density
Density from animals nobody marked: the gas model, the speed it needs, and the way round needing it.
- Camera trap density: the random encounter model - the gas model from the flux argument, tested across five detection zone geometries, and the product it cannot split.
- Measuring animal speed from camera traps - why the camera’s mean speed runs high, the exact harmonic mean fix, and the activity level assumption behind it.
- Staying time and the REST model in R - Little’s law and the chord identity give density with no external speed, until the clip length cuts the tail.
- Checking a camera trap density estimate - the independence filter, interval coverage in a patchy landscape, and the bias no diagnostic sees.
Closed capture-recapture
Mark a sample, look again, and read population size off the overlap. What decides whether that works is the failure of the closed-population assumptions, not the arithmetic.
- Closed-population capture-recapture - the classic mark-recapture estimators of population size.
- Capture heterogeneity: Mt, Mb and Mh - a trap response inflates abundance by a third and individual heterogeneity cuts it by a fifth, and AIC can tell which one you have.
- Mark resight abundance estimation in R - why individual heterogeneity leaves the abundance estimate alone but destroys the interval, and what the collared animals cannot tell you.
Spatial capture-recapture
Estimate density directly by modelling where each individual lives, not just how many were seen.
- Spatial capture-recapture from scratch - a full-likelihood SCR model with latent activity centres.
- Bayesian spatial capture-recapture - parameter-expanded data augmentation with latent locations.
- SCR sampling design and precision - trap spacing against sigma, and the U-shaped precision curve.
- Detection covariates and checking in SCR - effort on the detection function, and a bootstrap goodness-of-fit check.
Multi-state capture-recapture
Marked individuals move between states or sites between captures, and state-specific detection can masquerade as movement.
- Multi-state capture-recapture - the Arnason-Schwarz model and its forward likelihood by hand.
- Estimating transition probabilities - movement between states, and the detection gap that confounds it.
- Multi-event models for uncertain states - an observation layer for states that are recorded with error.
- Checking multi-state models - a bootstrap goodness-of-fit test that exposes hidden memory.
Open-population abundance
Survival, recruitment and abundance from the same capture histories, with three levels of exposure to the one assumption you cannot test.
- Jolly-Seber and POPAN: abundance from marks - a superpopulation layer on an unchanged CJS core, and where every new number comes from.
- Pradel seniority: growth rate from reverse time - the same code with the columns reversed, and why the delta interval is unusable.
- The robust design and temporary emigration - closed within primary periods, open between them, and the heterogeneity the design parameter absorbs.
- Checking an open-population model - a calibrated goodness-of-fit test with zero power against the error that matters.
Community and multi-species models
Model a whole assemblage at once: share information across species so the rare ones borrow strength from the common, and account for the species that were never detected.
- Multi-species occupancy models - a community occupancy model with a hand-coded Gibbs sampler, and how partial pooling steadies sparse-species estimates.
- Species richness by data augmentation - counting the undetected tail of a community, and why it beats a Chao estimator.
- Community covariates and species traits - a per-species slope on a site gradient, with a trait to explain the variation.
- Checking a community occupancy model - a posterior predictive check for unmodelled detection heterogeneity.
Integrated and multi-scale models
Join data of different kinds, or model a process at more than one spatial scale, in a single likelihood that no single data set could support on its own.
- Integrated species distribution models - presence-only records and a structured survey in one likelihood, correcting sampling bias.
- Multi-scale occupancy models - separating site use, local availability and detection, and the bias from skipping the middle scale.
- Spatial autocorrelation in occupancy models - Moran eigenvector filtering when a latent spatial gradient inflates false positives.
- Checking an integrated SDM - a targeted check for a conflict between two data sources that ordinary goodness of fit misses.
Spatial point patterns
Treat the locations themselves as the data: are events clustered, regular or random?
- Complete spatial randomness and quadrat tests - the null model every point-pattern method is measured against.
- Nearest-neighbour analysis and Clark-Evans - a first test of clustering from nearest-neighbour distances.
- Ripley’s K and the pair correlation function - structure across a range of scales at once.
- Two-species point patterns: testing for interaction - toroidal shift and random labelling test different hypotheses, and on a shared environmental gradient one of them calls independent species associated.
- Modelling inhomogeneous point patterns - separating a density trend from interaction between points.
- Checking a point pattern analysis - what a simulation envelope costs when it is read as a test, why the 199 simulation convention lands near five per cent by arithmetic, and the global test that has a level.
Movement and space use
Follow individuals rather than sites: where an animal ranges, how it moves, and which habitat it selects.
- Home range with MCP and KDE - minimum convex polygons and kernel density estimates, and why bandwidth drives the answer.
- Step lengths and turning angles - describing a movement path, with circular statistics done by hand.
- Resource selection functions - used-available logistic models, and why the fitted value is relative, not a probability.
- Correlated random walks - the diffusion null for movement, and telling ranging from directed travel.
- Fitting a two-state movement HMM - a hidden Markov model for encamped versus transiting movement, fitted by hand.
- How many states in a movement HMM? - choosing the number of behavioural states without overfitting.
- Covariates in a movement HMM - letting the transition probabilities depend on time of day.
- Checking a movement HMM - pseudo-residuals and decoding uncertainty for a fitted model.
State-space models for movement
Separate the animal’s true path from observation error, and say how much the data can resolve.
- State-space models for animal movement - a Kalman filter and smoother for a noisy correlated random walk.
- Regularising irregular animal tracks - a continuous-time model that fills gaps and gives honest uncertainty.
- A particle filter for animal movement - a bootstrap filter for heavy-tailed, contaminated location error.
- Checking a state-space movement model - one-step innovations, and why residual autocorrelation is the main diagnostic.
Step selection
Ask what an animal chooses from what was available to it, step by step.
- Step selection functions for animal movement - matched used and available steps with a conditional logistic likelihood.
- Integrated step selection analysis - de-biasing habitat selection and recovering the movement kernel.
- Availability sampling for step selection - how many control steps, and why the count sets precision not bias.
- Validating a step selection model - used-habitat calibration plots for a fitted selection model.
Population dynamics and matrix models
Project a population forward from its vital rates, and find which rates matter most.
- Life tables and population growth - from age-specific survival and fecundity to the growth rate.
- Leslie matrix population models - the age-structured projection matrix and its dominant eigenvalue.
- Stage-structured Lefkovitch matrices - when stage, not age, sets an individual’s fate.
- Sensitivity and elasticity of matrix models - ranking vital rates for conservation action.
- Stochastic population growth - how environmental variance pulls the long-run growth rate below the mean-matrix value.
- Extinction risk and population viability - a count-based PVA, and why a short series leaves the risk almost undetermined.
- Transient dynamics of matrix models - short-term amplification and attenuation before the stable structure settles.
- Life table response experiments - decomposing a difference in growth rate into contributions from each rate.
- Checking a matrix population model - primitivity, irreducibility, stage duration and the interval on lambda, before the eigenvalue is quoted.
Integral projection models
The continuous-size successor to matrix models: a kernel built from vital-rate regressions, with no need to bin individuals into stages.
- Building an integral projection model - from survival, growth and fecundity regressions to a kernel and its dominant eigenvalue.
- Eviction and mesh in an IPM - two numerical traps of discretisation, and how to separate them.
- IPM sensitivity and elasticity - the matrix sensitivity formula on a continuous kernel, including the empty-corner trap.
- Life expectancy and passage time in an IPM - individual demography from the fundamental operator, and why the naive estimate misleads.
Integrated population models
Join counts, capture-recapture and productivity in one likelihood to estimate demographic rates that no single data set identifies.
- Integrated population models from scratch - joining three data sets, and why counts alone cannot split survival from recruitment.
- Implicit information in integrated models - how the model estimates a rate it has no direct data for.
- Demographic and environmental variance in an IPM - separating the two variance components, and when it is identifiable.
- Checking an integrated population model - testing each component, and whether the data sets agree.
Survival and time-to-event
Estimate how long individuals live from censored, known-fate or recapture data, correcting the bias in a naive mean.
- Kaplan-Meier survival curves - non-parametric survival from censored times, with the log-rank test.
- Cox proportional hazards - a hazard ratio per covariate, and how to test the proportional-hazards assumption.
- Nest survival with logistic exposure - daily survival rates from intervals of unequal length.
- Cormack-Jolly-Seber survival - apparent survival for an open population from capture histories.
- Joint live-dead models: survival or fidelity? - dead recoveries split apparent survival into true survival and site fidelity.
Survival extensions
Go beyond a single event and proportional hazards: competing causes, parametric models, dependence between times, and how to check the fit.
- Competing risks and cumulative incidence - why one minus Kaplan-Meier overstates a cause, and the Aalen-Johansen estimator that fixes it.
- Parametric survival and the AFT model - Weibull and log-logistic fits, the accelerated failure time reading, and what a parametric model buys.
- Frailty and recurrent event models - shared frailty for clustered survival, and Andersen-Gill for repeated events on the same individual.
- Time-varying covariates in a survival model - writing an ever-changed label back to time zero grants immortal time, and the counting-process coding removes it.
- Checking a survival model - the proportional-hazards test, functional form, and the two things a diagnostic cannot do.
Population time series
Infer process from a run of annual counts: density dependence, hidden state, trend shape and the form of regulation.
- Detecting density dependence - a Gompertz test that avoids the bias of the naive approach.
- Gompertz state-space model - separating process from observation error with a hand-coded Kalman filter.
- Estimating population trends - linear versus GAM trends, and modelling counts as counts.
- The theta-logistic model - the shape of density dependence, and why one series can barely identify it.
- Decline estimates and Red List criterion A - turning a trend into a percentage reduction and a threat category, where the assumed generation length moves the answer further than the survey noise does.
Exact stochastic simulation
Populations change by whole animals, one event at a time. These posts build the sampler that reproduces that exactly, and measure what every shortcut costs.
- The Gillespie algorithm from scratch - the two draws that make it exact, checked against a stationary distribution known in closed form.
- Tau leaping and the cost of a bigger step - error against work, and why the mean forgives a large step while the variance does not.
- Mean time to extinction, exactly - the double sum, the quasi-stationary distribution, and where the diffusion approximation drifts.
- Checking a stochastic simulation - replicate counts, a deliberate bug, survivorship in the output, and seeds.
Fisheries stock assessment
An assessment turns a catch record and an abundance index into a number a manager acts on. The arithmetic is population dynamics with removals, and most of the difficulty is that the data constrain the answer far less than the output suggests.
- Surplus production models in R - a biomass dynamics model fitted to catch and an index, the reference points that come out of it, and why a stock that only ever declined cannot separate growth rate from carrying capacity.
- Stock-recruitment and reference points - Beverton-Holt and Ricker in terms of steepness, per-recruit arithmetic, and a target that moves with an assumption the data barely constrain.
- Standardising catch per unit effort - removing fleet and season effects from an abundance index, the prediction step people get wrong, and the hyperstability no model can standardise away.
- Checking a stock assessment - the retrospective pattern, contrast as a check you can run before fitting, the price of assumed parameters, and harvest control rules under estimation error.
Plant and animal phenology
Turn field dates into timing you can analyse, and watch how sampling effort, not the season, can drive an apparent shift.
- Phenology in R: day of year and event timing - convert field dates to day of year, treat a season as a distribution rather than a single date, and use circular statistics when timing wraps around the year.
- First flowering dates and sampling effort - why the first date advances as monitoring effort grows while the mean and median stay put, the extreme-value bias behind spurious phenological shifts.
- Phenological trends and temperature - estimate sensitivity to spring temperature, and see how rising effort in warm years inflates the first-date trend while the mean date holds.
- Quantifying phenological mismatch - warming that closes the gap between peak demand and peak food can leave consumers hungrier, and the trend in a difference is the weakest series in the study.
- Checking a phenology analysis - three checks: does the estimate survive thinning, is the season censored by the survey window, and do the summaries agree on the trend.
Climate covariates
Turning a weather record into the variable an ecological model actually needs, and measuring how much of the answer the construction decides.
- Degree days and thermal time in R - three routine ways to accumulate thermal time from daily extremes, and why the assumed base temperature moves the predicted date further than warming does.
- Drought indices for ecologists - a water balance, the standardised precipitation index and its evapotranspiration cousin by hand, and how the accumulation window and the baseline period decide which years count as drought.
- Climate window analysis in R - searching every window for the best climate predictor, the false positive rate that search produces on pure noise, and the randomisation null that repairs it.
- Checking a climate window analysis - shared trends, competing climate variables, held-out years, and a window that is statistically sound and biologically wrong.
Climate velocity and range shifts
How fast the climate moves across the ground, how fast species follow, and how much of the measured gap between the two is measurement.
- Climate velocity in R - the local temporal trend over the local spatial gradient, built from the arithmetic up, and why the map is largely terrain and the mean is largely a flooring rule.
- Range shifts and the climate lag - four ways to define a range edge, the bias each one carries when survey effort changes, and what that leaves of an estimated climatic debt.
- Checking a range shift analysis - resurvey effort, the null distribution of a shift, elevation against latitude, and the community temperature index taken apart.
Species competition and coexistence
Fit competition coefficients from a field experiment, turn them into coexistence quantities, and see how far past the data the verdict actually reaches.
- Fitting annual plant competition models - fit Beverton-Holt competition coefficients from a response-surface experiment, and why an additive design cannot identify self-limitation.
- Niche and fitness differences - turn fitted coefficients into a niche difference and a fitness ratio, and see why the stronger competitor need not exclude its rival.
- Assumptions behind coexistence - the invasion verdict is an extrapolation far beyond the data; how model form and germination rates decide it where no data reach.
- Checking a coexistence analysis - three checks: mutual invasibility over time, whether the design identifies self-limitation, and stability of the verdict to model form.
Seed and propagule dispersal
Fit the density that describes where offspring land, and treat the far tail with the suspicion it deserves, because that is the part that sets spread and connectivity.
- Fitting dispersal kernels in R - seed-trap distances are not the location kernel, and the missing ring-area factor doubles the fitted scale if you ignore the geometry.
- Fat-tailed dispersal kernels - several families fit the same seed rain and agree on the bulk while disagreeing by orders of magnitude about long-distance dispersal.
- The mean dispersal distance - the mean averages over a tail no trap ever sampled, is weakly identified, and for some fitted kernels does not exist at all.
- Checking a dispersal kernel - three checks: how much the tail rests on a few seeds, whether the trap window truncates it, and whether the answer survives a change of family.
Invasion spread
How fast a population moves across a landscape, and what decides whether a single speed exists at all.
- The speed of an invasion front - the asymptotic speed in closed form from the moment generating function, checked against a simulated front, and why a handful of individuals at the leading edge set it.
- Fat tails and accelerating spread - a fat-tailed kernel has no asymptotic speed at all, so the front accelerates, and two kernels the seed data cannot separate diverge by a multiple inside one forecast.
- Long-distance jumps and stratified spread - rare jumps found colonies that spread in turn, which multiplies the mean speed and multiplies the spread of the forecast much harder.
- Checking an invasion spread model - the front definition, a lag that detection delay imitates exactly, and the Allee effect that breaks the linearised speed formula.
Metapopulation dynamics
Colonisation and extinction across a patch network: the classic model, fitting it from one snapshot, and the single number that ranks a landscape for persistence.
- The Levins metapopulation model - colonisation and extinction in a single equation; why the occupied fraction settles below one and equals one minus the extinction to colonisation ratio.
- The incidence function model - fit colonisation and extinction from a single occupancy snapshot with no turnover data; area proxies extinction, connectivity proxies colonisation.
- Metapopulation capacity - the leading eigenvalue of the landscape matrix as one number that ranks landscapes for persistence, and why a few patches dominate it.
- Checking a metapopulation model - three checks: a transient snapshot hides the area to extinction signal, alpha is weakly identified, and stochastic extinction rises at narrow margins.
Bayesian computation
Build the machinery of Bayesian inference by hand, and read the diagnostics that tell you it worked.
- Metropolis-Hastings from scratch - a random-walk sampler, and why a credible interval beats a Wald interval here.
- Gibbs sampling with conjugate updates - full conditionals for a mean and variance, checked against the exact answer.
- Slice sampling from scratch - stepping out and shrinkage, and the measured claim: it buys insensitivity to the one setting rather than a higher peak efficiency.
- MCMC convergence diagnostics from scratch - split R-hat and effective sample size, and a chain that looks fine but is not.
- Bayesian hierarchical models with MCMC - partial pooling and a posterior predictive check, by hand.
- Bayesian model comparison: WAIC, LOO, DIC - out-of-sample scores from the log-likelihood matrix.
- Choosing priors: flat is not uninformative - how a flat prior can be strong on the scale you care about.
- Bayesian logistic regression under separation - when the MLE diverges and a weakly informative prior rescues it.
- Bayesian occupancy with latent-state MCMC - a Gibbs sampler with data augmentation for the latent presence state.
Gradient samplers and approximations
What Stan is doing, why a hierarchical model can sample badly without being wrong, and how to tell that the computation returned the posterior you asked for.
- Hamiltonian Monte Carlo from scratch - the leapfrog integrator, the accept step that repairs it, and effective sample size per gradient.
- The Laplace approximation in R - a Gaussian at the mode, the marginal likelihood it gives you, and three named ways it fails.
- Reparameterisation and Neal’s funnel - the same model written two ways, and the crossover where the textbook advice reverses.
- Variational inference from scratch - coordinate ascent on the ELBO, and the uncertainty a mean-field family throws away as a function of the correlation it refuses to see.
- Bridge sampling for marginal likelihoods - the integral the Laplace approximation was approximating, estimated properly, and what the harmonic mean estimator does instead.
- Reversible jump MCMC from scratch - a chain that moves between models of different dimension, the Jacobian that nothing warns you about, and why the model probabilities keep depending on the prior.
- Checking a Bayesian computation - an exact benchmark, simulation-based calibration, divergences, and Monte Carlo standard error.
Bayesian latent-state models
The same latent-variable move applied to classic ecological models, sampling the hidden quantity directly.
- Bayesian Cormack-Jolly-Seber survival - the latent alive state sampled by hand, the Bayes pair of the m-array model.
- Bayesian N-mixture abundance - latent site abundance on a discrete grid with conjugate updates.
- Bayesian state-space movement - the latent path sampled with forward-filter backward-sample.
- Bayesian closed capture-recapture - unknown population size by parameter-expanded data augmentation.
Inference without a likelihood
Some models are simple to simulate and hopeless to write a likelihood for. Approximate Bayesian computation fits them anyway, by comparing simulated data with the data you have.
- Approximate Bayesian computation from scratch - fitting a model you can simulate but cannot write a likelihood for.
- Choosing summary statistics for ABC - in ABC the summaries are the data, and picking them badly costs more than the tolerance does.
- ABC-MCMC and sequential ABC samplers - a better sampler cannot buy more than the prior-to-posterior volume ratio, and here that is a factor of ten.
- Checking an ABC analysis - rank calibration audits the sampler, not the model, and it passes an analysis that has learned nothing.
Stable isotope mixing models
Work out what a consumer ate from its isotopes: the mixing geometry, a Bayesian fit by hand, and the assumptions that move the answer more than the data.
- Stable isotope mixing models in R - the geometry of source mixing: mass balance, the mixing polygon, and why two tracers cannot pin down four sources.
- Bayesian stable isotope mixing models - a Metropolis sampler from scratch; the wide correlated posterior, and how summing similar sources recovers a tight estimate.
- Discrimination and concentration in mixing models - how the assumed trophic discrimination factor and source concentrations move the diet estimate more than the data do.
- Checking a stable isotope mixing model - three checks: is the consumer inside the polygon, is the posterior data-driven or prior-driven, and does aggregation hold.
Isotopic niche
The same isotope values read as a niche rather than a diet: how wide a group’s isotopic space is, where it sits on the food chain, and how far two groups overlap.
- Isotopic niche width: hulls and ellipses - the convex hull area grows with sample size without bound while the corrected standard ellipse does not, so unequal samples decide a hull comparison.
- Trophic position from stable isotopes - trophic level from nitrogen, the baseline it is measured against, and why the assumed discrimination factor carries most of the error high up the chain.
- Isotopic niche overlap between groups - ellipse overlap is asymmetric and depends on the containment probability you pick, and two consumers with no shared prey can overlap completely.
- Checking an isotopic niche analysis - sample size and power, lipid correction, the pipeline decisions that change the verdict, and what tissue turnover does to a comparison.
DNA metabarcoding
A metabarcoding run returns a table of read counts whose row totals were set by the sequencer. Between the animal that ate something and that table sit DNA extraction, amplification, index assignment and a filtering decision, and each of them leaves a measurable mark.
- Metabarcoding reads as compositional data - relative read abundance and frequency of occurrence answer different questions and fail in different ways, and the detection threshold decides which taxa exist.
- PCR bias and amplification efficiency - why a small per-cycle difference becomes a large error, why the log-ratio is the right scale, and what a mock community can and cannot correct.
- Contamination filtering in metabarcoding - three sources with three different signatures, four filtering rules scored against each other, and a rule that classifies better but analyses worse.
- Checking a metabarcoding analysis - rarefying against the alternatives, the bloom that makes every other taxon fall, PCR replicates that are not replicates, and the read depth a diet needs.
Meta-analysis
Pool effect sizes across studies, measure how much they disagree, and check whether the published record is a fair sample.
- Random-effects meta-analysis - Hedges’ g, DerSimonian-Laird and REML tau-squared, forest plots and coverage.
- Heterogeneity in meta-analysis - Cochran’s Q, I-squared with an interval, and a prediction interval for a new study.
- Meta-regression with moderators - explaining heterogeneity with a study-level moderator, and keeping the error rate honest.
- Dependent effect sizes in meta-analysis - several effects from one study are correlated, the naive standard errors are too small, and a three-level model puts the study back in.
- Checking for publication bias - funnel plots, Egger’s regression and trim-and-fill, with the limits of each.
- Effect sizes from incomplete reports - recovering a standard deviation from a median and quartiles before the pooling starts, and what a standard error read as a standard deviation does to the weights.
Structural equation models
Write down a causal diagram and fit it equation by equation: split an effect into direct and indirect paths, then test the structure itself.
- Path analysis: direct and indirect effects - standardised path coefficients and the tracing rules, and why a bivariate slope misleads.
- Latent variables in an SEM, from scratch in R - three imperfect indicators identify their own reliability, and every composite of them gets the slope wrong.
- Piecewise SEM and d-separation - fitting a model with lm and glm, then testing it with Shipley’s d-separation and Fisher’s C.
- Mediation and bootstrapped indirect effects - why the product of two coefficients needs a bootstrap percentile interval, not Sobel’s.
- Checking a structural equation model - calibrating Fisher’s C with a bootstrap, and why Markov-equivalent graphs cannot orient the arrows.
Causal inference
Estimate a causal effect from observed data by choosing what to adjust for on purpose, and check the one assumption you cannot test.
- Confounding and backdoor adjustment - which covariates the backdoor criterion says to adjust for, and why adjusting for a mediator is a mistake.
- Collider bias and selection - how conditioning on a common effect, or sampling on it, manufactures a correlation that is not there.
- Before-after-control-impact designs - why a single before-after or control-impact comparison is biased, and how the BACI interaction differences it out.
- Checking causal assumptions - negative controls and the robustness value as honest bounds on an untestable premise.
- Instrumental variables and 2SLS - identifying an effect when a confounder is unmeasured, using an instrument and two-stage least squares.
- Front-door adjustment - a fully mediating measured mechanism identifies the total effect with no instrument, and the bias is the leaked direct edge one for one.
- Regression discontinuity design - identification from a threshold rule, comparing units just either side of the cutoff.
- Non-compliance in field experiments - assigned treatment is not received treatment, and intention-to-treat, per-protocol and the Wald ratio each answer a different question.
- Interference between experimental plots - treatment that leaks into the neighbours shrinks the contrast while the standard error stays put, and what a buffer strip costs to fix it.
- Propensity scores and inverse-probability weighting - reweighting by the probability of treatment to balance measured confounders.
- G-computation and standardisation - the backdoor adjustment written as an outcome model, averaged over the covariate distribution.
- Transporting an effect to a new region - the effect estimated where the plots were is not the effect where the policy acts, and standardising to the target covariate distribution can turn the sign around.
- Doubly robust estimation with AIPW - combining an outcome model and a weighting model so either one being correct suffices.
- Propensity score matching - pairing treated and control units on the score, and what it trades against weighting.
- Sensitivity to unmeasured confounding - E-values and how far a hidden confounder would have to reach to overturn a result.
Panel and comparative case studies
Estimate an effect from repeated observations across units and time, when a clean control group is not available.
- Event-study difference-in-differences - the dynamic DiD, its parallel-trends assumption, and reading the pre-treatment coefficients.
- Staggered adoption and two-way fixed-effects bias - why two-way fixed effects is biased under staggered timing, and the group-time alternative.
- The synthetic control method - building a weighted comparison unit when only one unit is treated.
- Placebo tests for panel causal designs - placebo-in-space and placebo-in-time checks that probe a panel estimate.
Measurement error
What error in a predictor or response does to an estimate, and what it takes to correct for it, including the chronological and calibration error that reconstructions carry.
- Measurement error and regression dilution - how error in a predictor attenuates a slope towards zero.
- Errors-in-variables and Deming regression - fitting a line when both variables carry error.
- Correcting measurement error with SIMEX - adding known error and extrapolating back to none.
- Age-depth models and what they do to a proxy - dating error in a core chronology becomes structure in the influx record, and a constant accumulation rate comes back as a fluctuating series.
- Weighted averaging transfer functions - inverse prediction from assemblages compresses the gradient to about half, deshrinking multiplies the noise back with it, and only the analogue check can refuse.
- Checking a measurement-error correction - reliability from replicates, and sensitivity to an unknown error variance.
Missing data
Why the reason data are missing matters more than how much, and how to analyse what is left honestly.
- Missing data: MCAR, MAR and MNAR - the three mechanisms, and why the distinction cannot be tested from the observed data.
- Single imputation: bias and variance - why filling gaps once understates uncertainty, even when the point estimate is fine.
- Multiple imputation by chained equations - MICE by hand, with Rubin’s rules for pooling estimates.
- Checking missing-data assumptions - diagnostics for the model and a delta-adjustment sensitivity analysis for MNAR.
Compositional data
When counts only make sense as proportions, ordinary correlation and distance mislead; log-ratios put the analysis back on firm ground.
- Closure and spurious correlation - how the constant-sum constraint manufactures negative correlations between parts.
- Log-ratio transformations: clr, alr and ilr - moving off the simplex into ordinary space, and what each transformation trades.
- Compositional analysis and the zero problem - a differential-abundance analysis done properly, and handling zeros before taking logarithms.
- Checking a compositional analysis - subcompositional coherence, residual checks, and the reference-frame limit as a tipping point.
Multiple testing and error rates
Testing many hypotheses at once inflates false positives; controlling the error rate is a choice with real power costs.
- Family-wise error and the Bonferroni correction - how the family-wise error rate grows, and the Bonferroni and Holm corrections.
- The false discovery rate and Benjamini-Hochberg - controlling the expected proportion of false discoveries instead of any false positive.
- Dependence and the Benjamini-Yekutieli correction - what dependence between tests does to the false discovery rate, and the conservative remedy.
- Checking a multiple-testing analysis - the p-value histogram, pi-zero estimation, and how sensitive the discovery set is to the chosen error rate.
Designing a survey
Choose where and how to sample so the estimate is unbiased and its variance is known, before any data are collected.
- Spatially balanced sampling with GRTS - drawing well-spread samples with the generalised random-tessellation stratified design.
- Design-based variance and spatial balance - why a spread sample estimates the mean more precisely, and how to quantify it.
- Unequal-probability spatial sampling - sampling some units more often on purpose, and correcting for it with the inclusion probabilities.
- Power for a community study - how many plots a PERMANOVA needs, and why the index decides.
- Checking a survey design - the design-based checks that a sample really is representative.
Monitoring design
Design a repeated survey to detect change over time, and know in advance whether it can. The second half of the section is the other half of the problem: a series only measures change if it stays comparable with itself while the taxonomy, the method and the recording effort all move under it.
Designing the repeat
- Variance components in monitoring data - splitting variation into site, year and residual, the pieces that set detectable change.
- Revisit designs for long-term monitoring - which sites to revisit and which to rotate, and what each choice buys.
- Power to detect a population trend - how many years and sites it takes to see a trend against the noise.
- Checking a monitoring design - the assumptions a trend estimate rests on, and how to test them.
Keeping the series comparable
- Taxonomic revision and species trends - a split and a lump partway through a long series manufacture a richness trend in a community that never changed.
- The price of harmonising a species list - putting two recording eras onto one backbone hides opposite trends, costs richness and drops records in a silent trait join.
- How long a calibration overlap do you need? - what a season of running both methods side by side buys in trend precision, how that compares with spending the same effort on more survey years, and which sites to dual-run.
- Testing a monitoring series every year - re-running the trend test as the series grows inflates the false alarm rate several times over, the first false alarm arrives early, and the estimate at stopping is steeper than the truth.
- Combining species trends into one index - the arithmetic mean of species indices climbs out of nothing, from spread among species and from small counts alike, and the geometric mean does not.
Opportunistic records and citizen science
Getting a trend out of records nobody designed, by modelling the effort that produced them rather than pretending it was constant.
- List-length analysis for opportunistic data - the length of a species list as a proxy for effort, two naive estimators that fail in opposite directions, and how much of the true trend is even reachable.
- Reporting rates and effort drift - a scheme that modernises while the species stays put produces a large false trend, and four kinds of drift ranked by how much damage each one does.
- Occupancy from unstructured records - building repeat visits out of a record stream, and why splitting one visit into two costs more than merging two into one.
- Checking an unstructured-data analysis - spatial and temporal bias needing different corrections, taxonomic reporting bias, the first-record trap, and validation against a structured survey.
Stratified sampling
Split a heterogeneous population into strata to sample each efficiently, then combine.
- Stratified random sampling in ecology - why stratifying cuts variance, and the estimator that reassembles the whole.
- Allocating survey effort across strata - proportional versus optimal allocation, and when the extra effort pays.
- Two-phase sampling when strata are unknown - a cheap first phase to build the strata, then a targeted second.
- Checking a stratified design - the checks that stratification helped rather than hurt.
Adaptive sampling
Let the data guide where to sample next when the target is rare and clustered.
- Adaptive cluster sampling in R - adding neighbours of every detection, and why it finds rare aggregations.
- Horvitz-Thompson for adaptive samples - the unbiased estimator that undoes the adaptive selection.
- When does adaptive sampling pay? - the rarity and clustering that make it worth the trouble.
- Checking an adaptive sampling design - the failure modes when the target is not clustered enough.
Checking the data against the design
A field season rarely returns exactly what the design specified, and nothing in a residual plot reports the difference. These measure what each gap costs, and the last one collects the checks that find them. Data provenance checks in R is the topic page for this section, with the species-list and unstructured-record cases from elsewhere on this page brought in alongside.
- Non-response and site substitution - the crew reaches fewer plots than were drawn and walks to the nearest reachable one instead, and what that replacement rule does to bias and interval coverage.
- Splicing a monitoring series - a change of method partway through reads as a trend, no ordinary diagnostic fires, and an era indicator recovers the real slope with no calibration data at all.
- Rounded and coarsened measurements - a known recording grid adds variance and makes a normality test reject the ruler rather than the biology, and an interval-censored likelihood puts both back.
- Values below the detection limit in R - substituting half the limit fabricates a trend when the laboratory improves, and the censored likelihood does not.
- Digit preference and heaping in field data - rounding that leans towards the round numbers moves the mean, and heaping that differs between two arms manufactures a contrast where there is none.
- Baseline selection and the return to the mean - targeting the worst sites returns a confident gain from a treatment that did nothing, while every pre-trend diagnostic stays quiet.
- Checking your data against the design - five checks that compare the returned data with the frame, the protocol dates, the recording grid, the allocation and the code list, each with the case it cannot see.
Allometry and scaling
Fit and compare scaling exponents on log-log axes, where the choice of line matters.
- Allometry and log-log regression in R - reading a scaling exponent off a log-log slope, and what it means.
- SMA or OLS for a scaling exponent? - why the standardised major axis, not ordinary regression, fits a scaling line.
- Testing isometry and comparing slopes - testing an exponent against a null and comparing groups.
- Fitting a body size spectrum - log bins shift the exponent by exactly one, and the likelihood that fits it needs no bins at all.
- Checking an allometric analysis - the assumptions behind a fitted scaling exponent.
Species associations and joint models
Model a whole community at once and ask what fitting them together adds.
- Joint species distribution models in R - what fitting a whole community at once changes, and what it leaves unchanged.
- Latent variables and species correlations - shrinking the species correlation matrix to something a survey can estimate.
- Co-occurrence is not interaction - why a residual correlation cannot name a mechanism.
- Copulas for dependent ecological data - why two skewed marginals cannot reach the correlation you asked for, and three dependence shapes tuned to the same Kendall’s tau that behave differently.
- Checking a joint species distribution model - the null maximum, the cost of presence-absence, and unrecorded effort.
Biodiversity and ecosystem function
How diversity changes what a community does, and how to partition the effect.
- Biodiversity and ecosystem function in R - the BEF relationship, relative yields, and why beating the average monoculture is not beating the best.
- Complementarity and selection effects - why the selection effect is a covariance, not a mechanism.
- Partitioning the net biodiversity effect - splitting the net effect into complementarity and selection, an exact identity.
- Ecosystem multifunctionality and its threshold - the richness slope of the threshold metric is a curve over thresholds, and the averaging metric hides it.
- Checking a biodiversity-function analysis - monoculture references, additive versus substitutive design, and one dominant species.
Litter decomposition and carbon
Turning mass remaining in a litterbag into a decay constant, and then into a carbon flux, without losing track of what each step assumed.
- Fitting litter decomposition curves - the single exponential fitted two ways, why the assumed error structure changes the answer, and how much of a decay constant is set by the length of the study.
- The recalcitrant pool and the asymptote - the two-pool and asymptotic models are close to indistinguishable on a real harvest schedule, and the schedule is worth more than extra bags.
- Mass loss and the carbon budget - carbon concentration drift, soil in the bags and fragment loss, and what the reciprocal of a decay constant does to a steady-state stock.
- Soil carbon stocks and equivalent soil mass - sampling both treatments to the same depth gives the denser soil more soil to hold carbon in, and the equivalent soil mass correction takes the invented difference back out.
- Checking a decomposition analysis - bags nested in plots, comparing treatments on the right scale, the fixed starting mass, and the number that lies outside the data.
Ecosystem carbon flux
A flux tower measures net exchange every half hour, and the annual budget that gets published is the output of a screening rule, a gap fill and a partitioning model. These five measure what each step decides, and a sixth takes the same question to a stream.
- Night-time flux and the u-star threshold - calm nights lose respired carbon before it reaches the sensor, the screening threshold is estimated rather than known, and its uncertainty carries into the annual sum.
- Gap filling a flux time series - the holes are not random, so the damage comes from the mechanism rather than the amount, and only look-alike matching reaches the noise floor.
- Partitioning net flux into GPP and respiration - the two gross fluxes are model output, their errors are correlated, and net exchange stays right while both move together.
- Stream metabolism from one oxygen logger - the aquatic counterpart, where depth and reaeration decide whether a day’s production estimate is a number or noise.
- Where the night-time flux comes from - the source area stretches upwind on stable nights, so the u-star screen selects on ground as well as on time, and the sign of that selection comes from the site’s own coupling between turbulence and stability.
- Checking an annual flux budget - six checks on a published sink: threshold uncertainty, the carbon share of filled half hours, night-biased gaps, what the error bar contains, and a defensible-choices multiverse.
Thermal performance and physiology
How performance depends on temperature, and what a variable climate does to it.
- Thermal performance curves in R - fitting the asymmetric curve of performance against temperature.
- Jensen’s inequality and thermal variability - why variable temperatures change mean performance, up or down with the curvature.
- Thermal safety margins and warming - the gap between optimum and environment, and why tropical species have less room.
- Checking a thermal performance analysis - acclimation, the mean-versus-variance trap, and extrapolation past the data.
Optimal foraging
What an animal should eat and where it should feed, and how to test it.
- The marginal value theorem - when to leave a depleting patch, set by travel time and the habitat average.
- Diet choice and the zero-one rule - why the optimal diet includes a prey type completely or not at all.
- Functional responses in R - the Holling curves of intake against prey density, and fitting them.
- Checking a foraging analysis - the currency, the handling-time trap, and when the theory does not apply.
Allee effects and small populations
Positive density dependence at low numbers, and the threshold it creates.
- Allee effects and thresholds in R - strong versus weak Allee effects and the critical density that decides extinction or recovery.
- Component and demographic Allee effects - how a mate-finding shortfall scales up to a population threshold, and when it stays harmless.
- Allee effects and extinction risk - why stochasticity endangers populations above the threshold, and why small introductions fail.
- Checking an Allee analysis - why detection needs low-density data and how sampling error fakes density dependence.
Life-history strategies
How selection shapes the timing of reproduction in a variable world.
- Life-history trade-offs in R - the cost of reproduction, the optimal reproductive effort, and why iteroparity pays when juveniles die young.
- Bet-hedging and geometric mean fitness - why fitness in a variable environment is the geometric mean, and how a steadier strategy wins.
- The optimal germination fraction - delayed germination as bet-hedging, and why the best fraction is less than one.
- Checking a life-history analysis - matching the fitness currency, the acquisition-allocation trap, and detecting bet-hedging.
Source-sink dynamics
How movement between good and bad habitat sets where a population persists.
- Source-sink population dynamics - how immigration keeps a sink occupied, and why abundance misleads about habitat quality.
- Ecological traps and pseudo-sinks - when a preferred habitat is a trap, and when a crowded sink is not really one.
- Why sinks hold high density - why the densest patch can be the worst one for fitness.
- Checking a source-sink analysis - separating birth and death from immigration, and the data it takes.
Habitat selection and the ideal free distribution
Where animals settle when they compete for patchy resources.
- The ideal free distribution - why competitors distribute themselves in proportion to resources.
- Density-dependent habitat selection - isodars, and reading habitat quality from how density splits across habitats.
- Input matching and undermatching - why real animals under-use the best patch, and what that reveals.
- Checking an ideal free analysis - the assumptions of free movement and equal competitors, and how they fail.
Evolutionary quantitative genetics
How selection on measured traits becomes evolutionary change across generations.
- Selection differentials and gradients - total selection versus direct selection, and the P inverse S identity.
- The breeder’s equation - predicting the response to selection from heritability, and where it drifts.
- The multivariate breeder’s equation - the G matrix, correlated responses, and genetic constraints.
- Nonlinear selection gradients - the quadratic coefficient is half the gradient, and a one-trait fit reads a saddle as disruptive selection.
- Qst against Fst: is the trait under selection? - the neutral drift null is wide and skewed, so the plain comparison calls selection on four or five neutral data sets in ten, and more populations do not repair it.
- Checking a selection analysis - collinearity, non-normal fitness, and the missing-trait problem.
The animal model
Heritability estimated from a pedigree rather than from a selection experiment, with the machinery written out by hand.
- The animal model in R - the relationship matrix, REML by hand, and why this is generalised least squares with a pedigree in it.
- Pedigree structure and heritability precision - what a pedigree needs before it can say anything, measured across four designs at the same sample size.
- Maternal effects inflate heritability - siblings share a nest as well as genes, and only the design can separate the two.
- Checking an animal model - pedigree errors, the denominator you chose, evolvability, and the boundary at zero.
Repeatability and individual variation
How much of the variation sits among individuals rather than within them, and what that number depends on.
- Adjusted repeatability in R - three different quantities all called repeatability, and the fixed effect that decides which way they move.
- Behavioural syndromes in R - the among-individual correlation, and the case where it has the opposite sign to the scatter plot.
- Behaviour sequences as Markov chains - transition matrices from an ethogram, testing for memory, and the time budget the act record does not give you.
- Checking a repeatability analysis - individuals against repeats, the interval between measurements, the observer, and the boundary.
Evolutionary game theory
What happens when the payoff to a behaviour depends on what everyone else does.
- The hawk-dove game and the ESS - animal conflict, the mixed evolutionarily stable strategy, and the invasion criterion.
- The replicator equation - game dynamics, convergence to an ESS, and rock-paper-scissors cycles.
- Sex ratio evolution and the ESS - Fisher’s argument, frequency dependence, and local mate competition.
- Checking a game theory model - payoff sensitivity, finite-population drift, and when the ESS is not reached.
The evolution of cooperation
How cooperation survives a game that defection wins on its own.
- The prisoner’s dilemma - why defection dominates a single encounter and cooperation collapses.
- Direct reciprocity and tit-for-tat - repeated interaction, the shadow of the future, and the reciprocity threshold.
- Strategies in the iterated game - why cooperation and defection are both stable, and the tipping point between them.
- Checking a reciprocity model - errors, the continuation probability, and the need for repeat partners.
Indirect reciprocity and reputation
Cooperation among strangers, when third parties know what you did.
- Indirect reciprocity and reputation - how reputation lets cooperation pay among strangers, and the threshold it needs.
- Assessment rules for reputation - image scoring, standing, stern judging and shunning compared.
- Public and private reputation - what happens to each rule when opinions are private rather than shared.
- Checking a reputation model - payoff sensitivity, seed replication, and drift in a finite population.
Network reciprocity and spatial games
What changes when neighbours interact instead of a well-mixed crowd. The arc runs from clustering on a lattice, to the replacement rule that decides whether the benefit-to-cost condition holds at all, to the Price equation split that says where the sign flips, and ends with the conventions a spatial result quietly rests on.
- Network reciprocity on a lattice - how spatial clustering keeps cooperation alive where a well-mixed population loses it.
- Update rules and cooperation on graphs - the benefit-to-cost rule on graphs, and why the replacement rule decides everything.
- Multilevel selection and group structure - splitting the Price equation between and within groups, and where the sign flips.
- Checking a spatial cooperation model - update timing, neighbourhood and boundary conventions, seeds, and whether the game matters.
Finite populations and gradual evolution
Selection is not the only thing moving once the population is small. These four build drift and fixation from the birth-death step up: the exact fixation probability of a single mutant, the thresholds that replace the ESS when chance matters, the branching point where one lineage becomes two, and how many replicates a fixation estimate needs before it means anything.
- The Moran process and fixation probability - birth and death in a finite population, the exact fixation probability of a single mutant, and how long fixation takes.
- Evolutionary games in finite populations - frequency dependent fitness, the one third law, and why risk dominance is a different threshold.
- Adaptive dynamics and evolutionary branching - invasion fitness, the selection gradient, pairwise invasibility plots, and when one lineage splits in two.
- Checking a finite population model - how many replicates a fixation probability needs, the wN scaling of weak selection, and cluster counting rules.
Population genetics
Allele frequencies carry their own record of drift, gene flow and sampling error. These four start from one locus in one population and end with the checks that decide whether a differentiation estimate means anything.
- Hardy-Weinberg expectations - expected genotype frequencies, the exact test, and why a heterozygote deficit is not evidence of inbreeding
- F-statistics and population structure - Fis, Fst and Fit from three heterozygosities, the ceiling on Gst, and an estimator that is not fooled by small samples
- Drift, migration and isolation by distance - the 1/(1 + 4Nm) equilibrium checked by simulation, and what a measured Fst does not tell you about migration
- Checking a population genetics analysis - loci against individuals, marker error against real structure, the cost of filtering rare variants, and outlier tests
Effective population size
The rate at which a population loses diversity depends on how it breeds, not on how many adults get counted. These four define that rate, estimate it from markers, and test what a crash leaves behind.
- Effective population size - the sex ratio, the variance in offspring number and the harmonic mean across bad years, each measured against its formula
- Estimating Ne from genetic data - the temporal and linkage disequilibrium estimators written out, and how much data each one needs
- Bottlenecks and genetic diversity - allelic richness, heterozygosity and the M ratio respond to a crash at different speeds
- Checking an effective size estimate - which time window, what siblings in the sample do, how wide the interval is, and what linkage costs
Coalescent theory and sequence diversity
Run drift backwards and the sample’s ancestry becomes the object of study. These four build gene trees, put mutations on them, and turn the resulting patterns into statistics with known failure modes.
- The coalescent and gene trees - exponential waiting times, tree height against total branch length, and why one gene tree is one draw
- Nucleotide diversity and Watterson theta - two unbiased estimators of the same parameter, one of them sharper, and the neutral frequency spectrum
- Tajima’s D and the frequency spectrum - growth pushes it negative, population structure positive, and a bottleneck fattens both tails
- Checking a coalescent analysis - what one locus supports, what recombination buys, whether demography imitates selection, and where to spend effort
Genetic clustering and assignment
The bar plot that appears in nearly every population genetics paper, built from scratch: what the model actually says, why the number of clusters is a model choice rather than a count, and the narrower question that has a measurable error rate.
- Admixture and ancestry proportions in R - the K-source ancestry model fitted by EM, and the three things that decide whether a bar plot means anything.
- Choosing K in genetic clustering - three criteria compared, and what they choose on a landscape with no discrete populations in it.
- Assignment tests and self-assignment - assigning individuals to a baseline, the self-assignment flattery, and the source you never sampled.
- Checking a genetic clustering analysis - uneven samples, linked loci, run-to-run variation, and what survives a subsample.
Landscape connectivity
Habitat pattern and movement cost, with every algorithm written out in base R rather than called from a GIS package. These four go from describing the pattern to testing whether a connectivity map means anything.
- Patch metrics and fragmentation - patch labelling by hand, the percolation threshold, and why the grain changes the data and not just the metric
- Least-cost paths and resistance surfaces - cost distance by iterative sweeps, and how much of the route the resistance values decide
- Circuit theory and effective resistance - the experiment least-cost paths fail: a second corridor that only one metric can see
- Checking a connectivity analysis - calibrate the metric, test what it predicts, vary the transform, change the grain
Landscape genetics
Genetic differentiation as the response variable and the map as the predictor. These take the resistance surfaces of the previous section and ask whether the genetic data support them, together with the inference problem that pairwise data creates.
- Isolation by distance and by resistance - linearised Fst against straight-line, least-cost and resistance distance on one simulated landscape
- Multiple matrix regression with MMRR - regression on distance matrices with a row and column permutation, and what the naive p-value costs
- Optimising a resistance surface - searching for the resistance values themselves, the ridge instead of a peak, and the null a tuned fit needs
- Checking a landscape genetics analysis - pair non-independence, a barrier confounded with distance, the lag after fragmentation, and marker precision
Conservation prioritisation
Turning biodiversity data into a plan: which sites, at what cost, in what shape, and how much of the answer was decided before the algorithm ran.
- Complementarity and reserve selection - what a site adds rather than what it holds, and why ranking by richness protects less for more
- Conservation costs and return on investment - the budget is money rather than area, so benefit per unit of cost is the ranking that matters
- Compactness in reserve design - the boundary length modifier and simulated annealing by hand, and the price of a tidy map
- Implementing a plan while land is lost - a static optimum bought over twenty years while unprotected units disappear, and the loss rate above which a myopic rule does better
- Ranking sites when every estimate is noisy - the top-ranked site is rarely the best one, shrinkage does not fix the order, and a rank interval says how far each site could move
- Checking a conservation prioritisation - greedy against the exact optimum, selection frequency instead of one map, data error, and the target as a value judgement
Reintroduction and restoration
Putting a population back, and measuring whether a site has recovered: allocation under a fixed number of animals, reserve configuration, and recovery measured against a moving target.
- Reintroduction release strategies - how to spend a fixed number of animals across years and stages, where the marginal animal stops paying, and the habitat problem no schedule can fix.
- SLOSS and reserve configuration - single large or several small, answered twice: by the beta diversity of the pool for richness, and by the spatial correlation of bad years for persistence.
- Restoration trajectories and recovery - the metric, the reference and the chronosequence each give a different recovery percentage, and a truncated series cannot see the asymptote.
- Checking a reintroduction analysis - the projection horizon, which uncertainty dominates, correlated vital rates, and a density dependence assumption a short series cannot test.
Decision analysis for conservation
Making the choice explicit: objectives and weights, what it is worth to reduce uncertainty first, and managing a system while still learning how it works.
- Structured decision making in R - a consequence table, dominance screening that needs no weights at all, swing weighting, and the normalisation choice that quietly changes the winner.
- The expected value of information - uncertainty that does not change the best action is worth nothing to resolve, and the survey accuracy below which no amount of data helps.
- Adaptive management and learning - model weights updated from outcomes, the action that pays best being the one that teaches least, and the horizon beyond which learning is worth its cost.
- Eliciting probabilities from experts - the four-point question, how far a stated ninety per cent interval falls below nominal, and the pooling rule the combined number quietly depends on.
- When decision makers disagree - four sensible aggregation rules on one agreed consequence table, three different winners, and what the compromise that avoids choosing costs.
- Checking a decision analysis - how firm the recommendation is, whether the uncertainty matters, what a new alternative does, and how risk attitude reorders everything.
Sequential decisions in management
When today’s action changes tomorrow’s state, the answer stops being a single choice and becomes a rule: what to do in each state the system can reach.
- Markov decision processes for management - value iteration over a dynamic state, why the output is a policy rather than a decision, and a rule that holds still while its own reported value moves.
- Stochastic dynamic programming for harvest - deriving the escapement rule instead of comparing fixed ones, and why the shape of the payoff bends it where recruitment noise does not.
- When to stop monitoring - monitoring as an optimal stopping problem, the price of surveying until significance, and the gap between statistical power and decision relevance.
- Checking a sequential decision model - the discount rate, a state grid coarse enough to invent a permanent cure, an estimated transition matrix, and the end of the horizon.
Janzen-Connell and species coexistence
A mechanism that punishes a species for being common, in four steps: what it does to diversity, how it is measured on a single seedling, why it stabilises coexistence, and the confound that erases it.
- Janzen-Connell and tree diversity - how specialised natural enemies near parent trees maintain diversity.
- Conspecific negative density dependence - measuring how a species survives worse among its own kind.
- Rare-species advantage and coexistence - negative frequency dependence and the invasion criterion.
- Checking a CNDD analysis - the habitat confound, estimation bias, and enemies versus competition.
Fluctuation-dependent coexistence
How a changing environment lets competitors coexist that a constant one would not.
- The storage effect and coexistence - how a fluctuating environment lets competitors coexist through the lottery model and buffered growth.
- 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.
Alternative stable states and tipping points
When a community has more than one outcome, and history or a slow driver decides.
- Priority effects and alternative stable states - how strong mutual competition makes the winner depend on who arrives first.
- Basins of attraction - mapping which starting abundances lead to which stable 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.
Disease ecology and epidemics
How pathogens spread through host populations, and the thresholds that govern them.
- The SIR epidemic model - susceptible, infected and recovered compartments, and the reproduction number that decides spread.
- R0 and herd immunity - why immunising a fraction one minus one over R0 stops an epidemic.
- Host density and endemic disease - the host-density threshold for invasion and the endemic prevalence.
- Checking an epidemic model - density versus frequency transmission, R0 from growth, and superspreading.
Epidemic dynamics and estimation
Beyond the basic compartments: what latency does to the numbers you measure, how to get a reproduction number out of a case series, and why endemic disease returns in waves.
- The SEIR model and the latent period - adding an exposed class leaves the reproduction number untouched and changes the growth rate, so a growth rate read through the wrong model gives the wrong answer.
- Estimating R0 from incidence data - the exponential growth rate mapped through a generation interval, the renewal equation for a time-varying reproduction number, and why cumulative counts give false precision.
- Prevalence from an imperfect test - apparent against true prevalence, the Rogan-Gladen correction, and what the validation study’s own uncertainty does to the interval.
- Force of infection from age prevalence - the catalytic model as a cloglog GLM with a log age offset, and the two mechanisms one cross-section cannot separate.
- Seasonality and recurrent epidemics - the intrinsic damped oscillation, the forcing amplitude that turns an annual cycle biennial, and the community size below which the pathogen fades out.
- Checking an epidemic estimate - four checks on the data rather than the model: reporting delay, time-varying under-reporting, weekly aggregation, and an assumption sweep priced against the model’s own interval.
Designing and exporting a figure
The design decisions inside a figure are measurable, and the wrong one costs the reader accuracy rather than taste. The last step, getting it out of R at the size and resolution a journal asks for, is part of the same job.
- Choosing colours for ecological data - sequential, diverging and qualitative as a question about the data, the lightness inversions a rainbow ramp creates, and a colour vision check that ends in a number.
- Designing an ordination figure - distance is the content, so the shape of the panel is part of the analysis, and the stress a two-dimensional map cannot show you.
- Effect plots that show the data - what a bar of means hides, partial against marginal effects from one model, and what each of the three interval widths actually covers.
- Publication-quality ggplot figures - physical size, resolution and clean export with ggsave.
- Checking a figure - a truncated axis measured off the drawn scale, a title width checked against the panel from font metrics, colour vision loss, and the title read as a claim.
Common pitfalls
A few posts above are dedicated to mistakes that are easy to make and hard to spot. If something looks wrong, these are the ones to reread: pseudoreplication, common PERMANOVA mistakes, collinearity and VIF, when not to use Shannon, GLM residual diagnostics, offsets for rates and densities, comparing significance is not a test, and residuals as a variable.