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.
- Reading Excel field sheets into R - read_excel guesses column types from the first 1000 rows, so a later text entry becomes NA, and date serials need origin 1899-12-30.
- 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.
- ggplot2 facets: fixed or free axis scales - what scales = “free_y” does to trend lines read across panels, measured off the built plot, and a fixed-scale index as the fix.
- Recoding field data in R: ifelse, if_else, case_when - measurements into size classes: case_when takes the first true line, a catch-all swallows the NAs, ifelse drops dates, and cut() splits on the boundary.
- Summarising ecological data by group - group_by and summarise, and why the mean of proportions is not the pooled proportion.
- Missing values in summaries: na.rm and false zeros - what sum, mean and max return with NA, why sum(na.rm = TRUE) turns unwalked months into a false decline, and the per-visit mean and monthly GLM that remove it.
- Joining ecological tables without losing zeros - why an inner join drops absent sites and a left join keeps the zeros.
- Factor levels in R: reference groups and empty sites - which group lm compares against, the sites with no records that count() drops, and the silent NA from factor(levels = ).
- 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.
- Probability distributions in R: d, p, q and r - what dpois, ppois, qpois and rpois return, the off-by-one in “at least k” for counts, and checking nbinom, gamma and lnorm parameters by simulation.
- Simulating correlated variables in R - two correlated normals by hand, chol() on the right side of the draws, mvrnorm(), and why a correlation set on the log scale is not the correlation of the counts.
- Standard errors and confidence intervals - what SE actually measures, t-based CIs for a mean, and why coverage matters.
- What a p-value tells you, and what it does not - the p-value computed by t.test() and by counting simulated no-effect experiments, and why a repeat is significant only as often as the power at the true effect.
- Bootstrap confidence intervals - a first bootstrap: one statistic, one interval, ahead of the dedicated series in Bootstrap and resampling inference.
- Maximum likelihood by hand with optim() in R - write a negative log-likelihood, match glm() with optim(), avoid the underflowing product, then fit a curve glm() cannot.
- The delta method: standard errors for derived values - a standard error for a species optimum from glm() coefficients with vcov() and a numerical gradient, and why dropping the covariance makes it several times too wide.
- 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 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.
- Repeating an analysis for every site in R - one function per site with split, lapply and purrr::map, and three silent faults: sapply changing shape, a loop over nothing, and failed sites dropped from the mean.
- 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.
- When integrate() in R returns zero and says OK - an infinite-limit integral of a narrow density far from zero comes back as 0 with message OK, and how centring on the integrand and a second-route likelihood check catch it.
- Records on grid lines and floating point in R - one-decimal records sit on 0.1 degree grid lines; how floor(), terra and sf place them, and an integer fix.
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.
- Pielou’s evenness under unequal sampling effort - why J ranks two communities by effort, how rarefying to a common n repairs it, and why unequal richness needs a common coverage instead.
- 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, with the DCA gradient length as the main input rather than the verdict.
- Variance partitioning - how much variation environment and space each explain.
- Forward selection in RDA: ordistep or ordiR2step - the adjusted R2 ceiling that often returns an empty model when there is one real driver, and what switching it off costs.
- 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.
- betadisper with unequal group sizes - five plots against fifty: the default shrinks the small group’s dispersion, bias.adjust removes most of the false positives but not all.
- Repeated-measures PERMANOVA - what to permute when the same sites are resampled or visited before and after.
- 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.
- Standardising variables before clustering sites - z-score, range or MAD: the shape of the variables that carry no groups decides, and a range/SD check per variable shows which case you are in.
- 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.
- Permutation nulls that keep the map - Moran spectral randomisation for two maps at the same plots: a kernel fitted to the map stays near the level, neighbour graphs do not, and gradients need a residual basis.
- 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.
- Network robustness and secondary extinctions - the attack tolerance curve and R50, which belong to the removal order and the assumed dependence rule as much as to the web.
- Interaction rewiring and its sampling floor - the rewiring share of two webs against its closed-form sampling floor, and why records must be permuted as foraging bouts, shuffled only among bouts of equal length when bout length differs between years.
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.
Classical theory in R
The models that named the field: a predator and its prey, two consumers on one resource, a host and its parasitoid, and an island filling up. Each one is written out as code, integrated or iterated by hand, and measured rather than asserted.
- The paradox of enrichment in R - raising prey carrying capacity in a Rosenzweig-MacArthur model destabilises it through a Hopf bifurcation, and the cycle minimum falls far below any realistic extinction floor.
- Resource competition and the R-star rule - the species that draws the limiting resource to the lowest equilibrium level wins regardless of its maximum growth rate, and two resources turn the same geometry into coexistence or bistability.
- Aggregation and host parasitoid stability - the Nicholson-Bailey model is unstable at every parameter value, and what stabilises it is aggregated attack rather than parameter tuning.
- Island biogeography and turnover - richness settles where immigration balances extinction while the species list keeps changing, so a constant count is not a constant community.
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.
- Home vs away and local vs foreign in transplants - each criterion for local adaptation mistakes one main effect for adaptation, and the sympatric-allopatric interaction keeps its level only when populations, not plants, are the replicate.
- Chi-squared approximation may be incorrect - what the warning means for two proportions: where R warns, the default Yates correction runs far below the nominal level and costs power, while the N-1 chi-square and the mid-p run near it, above it at some points.
- Randomising treatments to plots in R - shuffle a balanced label vector with sample(), avoid the replace = TRUE and sample(14, 1) traps, and analyse paired plots as pairs: on a steep gradient, two-group tests on paired plots had less power than not pairing.
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.
- Vuong test for zero inflation, and what to use instead - against a Poisson the raw Vuong test almost never finds real zero inflation and the corrected one certifies the Poisson whenever the fit sits on the bound; use the score test or the boundary likelihood ratio test.
- 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.
- Negative binomial k from small host samples - from a few dozen hosts at low burdens k often has no finite estimate, and how those samples are reported can manufacture a k-burden relationship.
- 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.
- Log-linear models for three-way count tables - a count table as nested Poisson GLMs, marginal versus conditional independence, and when a table can be collapsed.
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.
- Observed power tells you nothing - power computed from the observed effect is a one-to-one function of the p value, so it cannot answer the question the referee is asking; the interval already in the output can.
- 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.
- Records as a test for trend - the expected number of records in an independent series is the harmonic number whatever the distribution, so another record year is not evidence on its own, and a trend test sees far more.
- Pretesting variances before a t test - checking equal variances first is itself a test, and the pooled t test is least safe in exactly the samples that pass the check.
- Deleting outliers before the test - deleting points flagged by standardised residual or Cook’s distance and refitting doubles the false positive rate on clean data, and deleting until nothing is flagged does worse.
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.
- AIC on REML fits: when units choose the model - lmer fits by REML by default, and an AIC across different fixed effects then moves with the units of the covariate; compare fixed effects with ML.
- 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.
- The scale of effect in landscape data - fitting the same model at eight buffer radii always returns a best one; the search takes the false positive rate from 0.03 to 0.17, and the landscape’s own grain sets how finely the radius can be resolved.
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.
- Bout-ending criteria and the histogram bin width - a two-exponential bout criterion fitted to a log histogram follows bin width and record length; likelihood on the gaps does not.
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.
- Parameter scale decides what optim() finds - a Ricker fit in (r, K) stops near its starting K because BFGS keeps restarting its search matrix, still reports convergence, and the linear form or parscale repairs it.
- Checking a nonlinear model - weighted fits for non-constant variance, and why the Wald interval can be over-optimistic.
- Individual growth curves with nlme - random asymptotes for sparse length at age, and why averaging per-fish nls fits inflates the spread when the oldest ages stop short of the plateau.
- Light response curves: the curvature you drop - the rectangular hyperbola’s bias on a curved leaf is fixed arithmetic, ten noisy points let AIC catch it about half the time at moderate curvature, and theta from one curve stays too loose to compare leaves.
- Growth from tag-recapture increments - Fabens fits to increments at unknown age, why asymptote spread and length error bias Linf and K in opposite directions, and what a joint likelihood inherits from its release-age model.
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.
- Derivatives of a GAM trend: when did it change? - the derivative of a fitted trend with a simultaneous interval localises a gradual decline, while a single breakpoint model on the same series puts the break on a plateau.
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.
- Confidence intervals in quantile regression - what summary() prints after rq(), and how often each interval covers when the spread fans out.
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.
- Tensor product smooths in mgcv - an isotropic s(x, z) charges the same price for wiggliness in both directions, so the recording units decide the fit, and te() takes that choice away.
- 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.
- Hierarchical GAMs and factor smooths in mgcv - separate by smooths against a shared curve with factor smooth deviations: what a sparsely sampled group borrows, which part of the penalty does the work, and why AIC is a weak guide.
- Choosing a factor smooth for a half-sampled group - a lake sampled on only the cold half of the gradient: the sz factor smooth runs an unpenalised straight line into the gap, penalising its null space brings it close to the global-shape models, and a lower penalty order is not a repair to rely on.
- Harmonics or cyclic splines for a narrow seasonal peak - s(day, bs = “cc”) with knots on the year ends against harmonics chosen by AIC or BIC: the smoothing criterion decides the width, and a plain smooth jumps at New Year.
- Overdispersion, year noise and a wiggly GAM trend - a Poisson trend smooth reads extra spread as wiggles; nb() removes spread between plots, while only a year random effect removes year noise, keeping the hump but lowering its peak.
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.
- Centring a quadratic before lasso or ridge - standardising leaves the origin of a squared covariate in place and a tuned penalty loses the hump; centring or poly() removes the origin.
- Tuned shrinkage and the penalty your data needed - a cross-validated ridge penalty is right on average but ranks opposite to the penalty each survey needed.
- Lasso, stepwise and the dropped confounder - choosing adjustment covariates by lasso or backward AIC drops a confounder the treatment absorbs; double selection, or adjusting for every candidate, keeps the interval honest.
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.
- Emulating a slow simulation model - a Gaussian process through a few dozen simulator runs: a grid design loses to a Latin hypercube, leave-one-out catches it, and the kernel decides whether the emulator’s own intervals can be trusted.
- Global sensitivity analysis with Sobol indices - first-order and total Sobol indices by hand for a stage matrix and a harvest model: the Taylor share from elasticity and input CV predicts them when the model is smooth, and the total index finds the interaction when it is not.
- Model discrepancy in simulator calibration - a linear intake simulator calibrated against a saturating truth: a GP discrepancy with a fixed amplitude keeps nominal coverage without learning the rate, and estimating that amplitude from the same data drops coverage to zero.
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 does not test the trait effect at all.
- 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.
- Zeros and ones in beta regression - why the usual squeeze makes the slope depend on sample size, and the censored and inflated beta models it stands in for.
- Likert items: when group means lie - a more polarised group can score lower on a lopsided 1 to 5 item with the same mean attitude; the t test, Wilcoxon and polr raise false alarms, and an ordered probit with a group scale holds unless the attitude itself is skewed.
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.
- NOEC rewards noisy toxicity tests - the no-observed-effect concentration climbs with replicate scatter and falls with replication, while a fitted EC10 from the same tests stays centred and only its interval widens.
- Integrated biomarker response and axis order - the star-plot axis order moves the most impacted station less often than a repeat survey does, and a mean of standardised scores finds it just as often.
- Sediment quality guidelines from co-occurrence - with strongly correlated chemicals the ERL/ERM incidence check passes an inert co-sourced chemical in contaminated databases and fails the real toxicant in clean ones; a joint logistic separates them unless a toxicant goes unmeasured.
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.
- Join counts for presence-absence maps - on a presence-absence grid the free sampling variance with an estimated prevalence almost never rejects, Moran’s I on the 0/1 map tracks the join count, and a sparse map needs a permutation test.
- 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.
- Moran’s I on residuals: moran.test or lm.morantest - residuals of a model with smooth predictors have a lower null mean, so moran.test and moran.mc lose size and power on them where lm.morantest does not.
- Spatial+ and the attenuated slope - a smooth of the coordinates only partly repairs a confounded slope; spatial+ repairs it when the covariate has plot-level variation, and says so through a wide interval when it has none.
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.
- Tree ring detrending and the segment length curse - detrending a ring series removes climate at periods longer than the series, EPS cannot see what was removed, and regional curves recover it only when the age trend is shared.
- Self-exciting events and the Hawkes process - a slowly varying background rate fakes self-excitation, a flexible background removes it only when its knots are far wider than the kernel, and gap-based residuals do not see the difference.
- Binning a time series invents a reverse cause - summing or averaging two series into coarser bins makes the follower appear to drive its driver; point samples at the bin end keep the direction when the dynamics are first order.
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 much 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 move the trend statistic.
- 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.
- Interpolated cores and false slowing down - interpolating an unevenly sampled core to a regular grid fakes rising autocorrelation when the spacing coarsens and flattens a real rise when it refines; a null simulated at the real sample ages and interpolated the same way corrects the 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.
- Smoothing a series before testing a forecast - a smoother fitted to the whole record flatters a one-step hindcast; refitted at each forecast origin, in the same pipeline, it loses to a raw AR(1), and a filter or an endpoint regression only ties it.
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.
- Leave-one-out AUC on a small survey - pooling held-out predictions ranks each site with a model refitted against its own label, so on a small survey with few presences a working model scores well below its true AUC; leave-pair-out does not.
- Classifier scores over a camera-trap sequence - why calibrated per-image scores give a miscalibrated sequence score: the closed-form slope of the averaged logit, what empty frames do to five pooling rules, and how many labelled sequences a recalibration needs.
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.
- Cluster bootstrap at six sites, and what beats it - with six catchments and a site-level treatment the pairs cluster bootstrap and the sandwich over-reject; the site means hold the level and the wild bootstrap has a floor of 2/2^G.
- The m out of n bootstrap - subsampling for a statistic the ordinary bootstrap gets wrong, where the rate exponent rather than the subsample size decides the interval.
- 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.
- Permutation tests with a covariate in the model - shuffling labels or the response mis-sizes a raw partial slope by closed-form factors; a t statistic or Freedman-Lane residuals repair both.
- Checking a bootstrap - where a non-smooth statistic breaks, and why more data does not always fix it.
- The jackknife and bias correction - the pseudo-values cancel the one over n term, which is what the jackknife is for, and the same estimator fails on a median where the bootstrap holds.
- Testing a fitted distribution - a Kolmogorov-Smirnov test run with parameters estimated from the same data almost never rejects, and calibrating the null by bootstrap restores both the level and the power.
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.
- Attributing one bad year to a warming trend - keeping the extreme year that started the analysis in a normal trend fit inflates the probability ratio, while in a GEV fit the shape parameter absorbs it.
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.
- Brownian motion or Ornstein-Uhlenbeck? - how often AICc invents a stabilising pull in Brownian trait data, and why tip error makes it worse.
- Checking a phylogenetic regression’s branch lengths - how often wrong branch lengths make PGLS reject a true zero slope, and why the Garland contrast check mostly flags the tree rather than the damaged dataset.
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.
- Choosing a projection for area and distance - sf now measures unprojected data on the globe (a sphere, through s2), so the old warning about square degrees is out of date, and what still costs is which projection you pick.
- Checking a vector layer before you measure - an invalid polygon does not throw, it answers, and a bowtie returns an area of exactly zero while a join against it still finds records.
- What a shapefile loses - the geometry round-trips exactly and the attribute table does not: field names abbreviated past recognition, a date-time reduced to a date, a logical returned as an integer.
- Coordinate error and habitat assignment - the share of records put in the wrong habitat class is set by the perimeter of the map rather than by the precision of the GPS, and the damage downstream is attenuation.
- Raster basics with terra - raster structure and map algebra.
- Slope and aspect: what a DEM does not measure - the neighbourhood rule and the cell size both change the slope you get, both of them through surface roughness, and aspect has to be split into northness and eastness before a model sees it.
- Rasterising a vector layer - the cell rule is a measurement, not a format conversion: the centre rule loses features narrower than a cell and the touches rule invents area in proportion to edge.
- When redrawing zones flips the sign - hold the unit count and the cells per unit fixed and move only the boundaries, and the reported relationship can change sign; a variance ratio says in advance whether your zones are able to do it.
- 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.
- Running QGIS from the command line - qgis_process makes the toolbox scriptable, and the comparison with sf and terra shows where the two engines agree byte for byte and where a default quietly parts them.
- Area in QGIS and R: which call matches which - every QGIS area (the project-ellipsoid
$area,area($geometry), a custom sphere) has an exact sf partner, and qgis_process without an ellipsoid returns the flat area of the layer. - QGIS NULL and R NA: what survives the trip - a QGIS filter treats NULL as false like dplyr, bare [ indexing adds rows of NA, and a CSV export merges NULL with empty text where a GeoPackage keeps them apart.
- Natural breaks in QGIS and R: Jenks on large layers - which QGIS classification modes match classInt, why Natural Breaks can differ even on a small layer, and why above 30009 features it classifies phantom zeros.
- Reprojecting a raster in QGIS and R: opposite defaults - QGIS Warp copies the nearest cell while terra project() interpolates unless the raster has a category table, so a land-cover map gains invented classes along its boundaries and a nearest-neighbour DEM leaves seams in slope.
- Georeferencing RMS is not accuracy - the Georeferencer reports the residual at its own control points, so it falls as the transformation is given more freedom and reads exactly zero for a spline that is still metres out between the marks.
- 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.
- Separable space-time covariance, tested - a product of a spatial and a temporal correlation factorises through a Kronecker product, but it fixes one spatial range at every time lag, and fitted to a non-separable truth it understates the cross-covariance.
- 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.
- Conditional simulation versus kriging - the kriged map is the best guess cell by cell and therefore too smooth for the area above a threshold, the peak or the patch count; conditional simulations get those right at the price of pointwise error.
- Spatial cross-validation when the target is a map - block folds overstate a random sample’s map error and random folds understate a clustered one’s; compare two distance distributions before drawing any fold.
- Geographical detector: the interaction rule - q is eta squared and fine as a description, but the interaction verdict follows sample size, the sign of the driver correlation and autocorrelation rather than interaction; neither toroidal shift test on a raster held its level in every design tried.
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.
- SDM fitted before the invasion is over - a species still spreading maps a third of its potential range, and the fitted optimum sits on the founding climate.
- Novel climate combinations and the MESS map - a warmer and wetter future can pass the one-covariate MESS check yet leave the correlated data; NT2 flags it, and the projection scatters far more widely across the sampled strip than along it.
- Coarse climate layers and a species’ niche width - plots read from a coarse climate grid get a wider niche; a pooled correction fails when cells differ in roughness, a per-cell Berkson fit does not.
- Validating an SDM against a resurvey - a projected SDM scored on a resurvey: the old map wins while few squares change state, the true niche misses many extirpations, and a lagging species fools the check.
- Richness from stacked SDMs: sum the probabilities - thresholded species maps added up over-predict richness and stretch its contrast; summed probabilities do not, and their Poisson-binomial interval fails under a shared driver.
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.
- The continuous Boyce index for presence-only SDMs - what records and window width do to the index, why any rising map scores near one, and what to report beside it.
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.
- Rapoport’s rule and the Stevens method - Stevens band means invent the rule wherever richness peaks, pole clipping biases species midpoints too, and dropping edge-touching species makes the false rule more frequent.
- The mid-domain effect as a null for richness - a central environmental hump fits the range-shuffling null with r-squared near 0.9; the envelope share, ranked among the null placements, and a species midpoint test tell geometry apart.
- Extrapolating a species-area curve beyond the plots - a power law from small plots wins on AIC and misses larger areas by a factor set by aggregation and pool saturation; run backwards, its overshoot of the species lost at once is largest when little habitat is lost.
- 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.
- Camera trap occupancy: choosing the occasion length - why daily camera occasions bias occupancy when detections come in runs, and what longer occasions cost.
- 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.
- Neighbourhood colonisation and false jumps - missed detections invent colonisations with no source, and the observed neighbour count pushes the effect up rather than down.
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, 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.
- Acoustic indices and species richness - simulated spectrograms showing that the sign of the acoustic entropy link to richness follows call energy against the noise floor, and that the ACI sign is set by note length.
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.
- Removal estimates when catchability falls - a per-pass fall in catchability drags the Zippin estimate low and its interval off the truth, a fit test with three passes barely notices, more passes do not help, and a release of marked fish adds the missing information.
- Declaring eradication after empty traps - a run of empty sessions sized from the removal capture rate is calibrated when every animal is equally catchable, but removal leaves the least catchable animals behind, and under strong heterogeneity neither extra sessions nor a heterogeneity model makes a declaration trustworthy.
- Time-removal point counts and observer arrival - song suppressed by the observer’s arrival pushes a time-removal estimate high for rare singers; the one-minute fit test sees it best where it matters least, and a settling period pays only up to a break-even departure rate that shifts with singing rate, reaction strength and when birds leave.
- Removal passes until the catch drops - stopping once a pass catches half the first trims the high tail of the removal estimate but leans it low, and its interval covers the truth less often at low catch probability.
- 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.
- Open N-mixture models and the detection trap - survival and recruitment from repeat counts with a hand-built forward algorithm: the repeat visits catch a drift in detection once detection may vary by year, while detection that falls with abundance pushes both rates off until a detection-on-abundance model of the right shape is fitted.
- Disturbed animals in repeated counts - when counting makes an animal harder to count again, the N-mixture and removal models both run high from opposite ends, a count-only Mb model with the number already counted recovers abundance, and with two visits nothing can tell it from a time effect.
- Change-in-ratio population estimates in R - population size from a sex ratio before and after a known harvest: the error grows as the ratio change shrinks, the median drifts once the change can flip sign, and a profile interval can have no upper end.
- Pitfall catches and the depletion zone - a removing trap in a random walk: the depletion zone bends the effort offset only a little, walking speed raises catches mostly through the encounter formula, and diffusion sets how much local density is left.
- Detection from a single drone flight - one pass gives one count per tile, so abundance and detection separate only through the curvature of the detection link: distinct covariates with a steep slope recover the total, a covariate shared with density widens the abundance band by a factor of 124, and a second flight cuts the detection standard error by 13.
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.
- Line transects along tracks and avoidance - animals that avoid the track fold into the detection function: over half the density lost, and the fit test catches the cheaper gradients.
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 the abundance estimate runs only slightly high while the interval collapses, and what the collared animals cannot tell you.
- Identification errors in capture-recapture - a missed photo match pushes abundance up and a false match pushes it down, a pair of rates can cancel in the estimate while coverage falls, and the frequency table cannot tell which error happened.
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.
- Spatial capture-recapture on a meandering stream - a planar state space inflates abundance several times over on a sinuous reach, a habitat mask repairs the count, and only along-stream distance repairs sigma.
- Trap-specific responses in spatial capture-recapture - an animal that learns one baited trap piles its recaptures there and shortens sigma; a global Mb cannot fix it, a trap-specific Mbk can, and AIC usually tells them apart.
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.
- Plotless density estimation from distances - density from point-to-tree distances, and why the assumption Clark-Evans tests is the one this method needs.
- Quadrat variance peaks and false second scales - TTLQV and PQV on a transect: one patch scale gives a harmonic second peak near three widths, so a peak count is not a scale count.
- Snapped coordinates and a clustering verdict - grid-stored records read as clustered, one record per cell reads them as regular, and an envelope built on the grid repairs both.
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.
- GPS fix loss and the collars you drop - canopy that blocks fixes biases an RSF, inverse fix-probability weights repair the points, and dropping low-success collars selects the animals instead.
- 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.
- Levy walk or patchy habitat: which test to trust - a Brownian walker whose speed changes with habitat can pass the power-law tail test; a mixture alternative and a lag-1 check catch it, except when speeds are redrawn every step.
- Accelerometer windows and short behaviours - window length puts a ceiling on which short behaviours a classifier can find, and the time budget falls more slowly than recall, so a good budget flatters the classifier.
- Depth sensor drift and the dive count - a slow drift in a dive recorder’s zero removes the shallow dives or merges the record for an unchanged animal, the loss is predictable from depths near the threshold, and a surface median puts the count back.
- Geolocator latitude near the equinox - invert daylength for latitude, measure the equinox gap and shading bias, and see Hill-Ekstrom calibration invent and erase shifts.
- Classifying migrants from net squared displacement - choosing NSD curves by AIC calls stationary residents migrants more often the slower they cross their range, and a displacement floor trades that against short migrants
- Home-range overlap is not contact - two animals on one range can meet rarely or often; a time-shuffle test for excess contact fires more often as tau grows, a circular time shift holds.
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.
- Missing GPS fixes in step selection - drop, weight or bridge the gaps when GPS fixes fail under cover.
- Familiarity covariates without memory - a familiarity layer from past fixes fakes memory when a habitat layer or home range is left out; a future-fix placebo scores real memory the same way.
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.
- Observation error in a count-based PVA - counting error inflates the variance of log growth so the naive risk sits high; three repairs, and where the naive risk does no worse.
- Extinction dates from sighting records - the Solow test’s false alarm rate under a declining sighting rate in closed form, and a linear estimation bound that falls short of its level on a rarely seen, dwindling population, more so with a larger k.
- 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.
- Seasonal matrix models and the census date - multiply the seasonal matrices from any census date and lambda does not move, but the published annual matrix and its elasticities do; rank seasonal vital rates instead.
- Red noise and extinction risk in a Ricker model - at the same noise variance, autocorrelated years raise extinction risk for an undercompensating population and lower it for an overcompensating one.
- Fertility control versus culling in R - culling and permanent sterilisation at the same treatment rate reach the same long-run census; on the post-treatment count sterilisation takes longer, the lag grows with survival, and part of that lead is the census point itself.
- Size-class boundaries in a matrix population model - equal-width classes versus sample quantiles, and how often a declining population comes out stable or growing.
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.
- Size measurement error in an IPM - how error in measured size inflates lambda, which vital rate carries it, and a remeasurement repair.
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.
- Transients and the single-capture rule in CJS - deleting birds caught once makes survival a readout of detection and study length; the two-age model and TEST 3.SR instead.
- Misread colour rings and apparent survival - misread codes that hit dead birds push CJS survival up more with every season; a two-sighting filter swaps that for a heterogeneity bias, and a detection term for the dead state takes out part of it.
- Census interval bias in tree mortality rates - annual mortality falls with the census interval when trees differ in unseen risk, the bias is exactly zero without that heterogeneity, and the usual correction overshoots.
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.
- Interval-censored survival from visit data - coding a death at the midpoint or at the detection visit can flip a falling Weibull hazard into a rising one, and the interval2 likelihood that does not.
- A state change seen only at visits - a state change coded at the midpoint of the visit interval manufactures protection even under the null, coding it at the detection visit shrinks a real effect, and an illness-death likelihood recovers the hazard ratio.
- Latency tests when some animals never respond - a share of non-responders turns one Cox hazard ratio into two effects, and a mixture cure model separates them if follow-up is long enough.
- Germination trials as time-to-event data - a final-count test reads a slower seed lot as a less viable one, and a cure-fraction interval likelihood separates speed from germinable fraction.
- Fire return intervals from a short scar record - a short fire-scar record makes the mean fire interval too short when fires are random, censoring both open gaps overshoots, and record length over fire count usually errs less.
- Lost collar signals and informative censoring - when dead animals silence their collars Kaplan-Meier runs high; a battery-curve likelihood fails with an optimistic curve and a cut-off rule is no safer
- Delayed entry and the Weibull hazard shape - fitting age at death without the marking ages inflates the Weibull shape and turns juvenile mortality into senescence; one extra likelihood term fixes it.
- Additive or compensatory harvest mortality - regressing survival on kill rate from the same collared animals manufactures additivity, more years make it surer, and a moment correction removes the bias at a large cost in noise.
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.
- Observation error estimated as zero in a Gompertz fit - a state-space fit to a short series often puts the observation error at zero; it is then an exact AR(1) fit that keeps the whole bias, and replicate counts, not restricted likelihood, bring the interval back.
- 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.
- Spatial synchrony and the Moran effect - with identical linear dynamics synchrony equals the correlation of the weather, dispersal is weak in a stable linear ring but locks cycling populations together, and nonlinearity breaks the equality.
- Fitting an ODE: trajectory versus gradient matching - random starts reach the best Lotka-Volterra fit about half the time because the sum of squares has a basin per cycle count, and gradient matching is a good start only while samples are dense.
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.
- Reconstructing a population from ages at harvest - cohort analysis returns the guessed harvest rate as the present-year population, the age likelihood at constant effort is an exact ridge, and known effort contrast identifies the rate unless catchability creeps.
- Fishing, age truncation and spawning variability - fishing old fish raises the CV of spawning output by a closed-form filter and flattens its spectrum, but a fifty-year index often misses the change and the naive variance test is oversized.
- Borrowed age-length keys and strong year classes - a key carried from another year halves a strong year class; the inverse EM key with a fitted growth curve recovers it, except where older ages overlap in length.
- Trawl selectivity when hauls differ - a covered-codend L50 fitted to pooled hauls covers the truth less than half the time once hauls differ by a centimetre, quasi-binomial does not see it, and the haul is the replicate.
- Gill-net selectivity and the fish it cannot see - a three-mesh series stops fishing right at the size the report is about, so the SELECT correction returns less than half of the large-fish share whichever family is fitted, and the repair is a fourth mesh rather than a better model.
- Earlier maturation: evolution or faster growth? - the age at maturity falls under faster growth alone; the PMRN midpoint does not, but at 100 fish per age it finds a real shift in the rule in fewer than six series of ten.
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.
- Daylength as a predictor in ecology - compute photoperiod in base R, see why it cannot beat day of year at one site, and why the latitude design that identifies it also confounds it.
- Curve registration and functional PCA - the day by day mean of shifted seasonal curves is too low and too wide, and whether registration is a shift or a pinned warp decides what a functional PCA calls amplitude.
- Chilling, forcing and projected leaf-out - a forcing-only degree day model overstates the spring advance under warming and misses the delay where winter chill runs out; the chill rule decides the projection.
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.
- Distributed lag models versus the climate window - a smooth lag weight fitted as an mgcv linear functional term: the searched window’s median slope sits near the total while its interval undercovers, the distributed lag interval stays near 95 per cent, and thirty years usually miss the peak lag.
- Reset time and the double-counted hot day - a min-max thermometer read in the afternoon carries a warm evening into the next day, inflating mean maxima and hot days, and a monthly correction fixes the mean but not the count.
- Heatwave counts: persistence, rule order, warming - the Hobday heatwave rules in base R: at the same share of hot days the count is set by persistence and by whether short runs are dropped before gaps are joined, and under warming it peaks and falls while heatwave days keep rising.
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.
- Misread rings and the dispersal tail - misread ring numbers link recoveries to the wrong site and fake a fat tail; a mixture with a null built from the ring register recovers the kernel.
- Seed dispersal: the nearest adult is not the parent - nearest-adult distances are capped by the tree spacing, a closed form in kappa; the inverse seed-trap model fails at wide kernels unless more seeds are caught.
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.
- Critical patch size and the dispersal kernel - the kernel eigenvalue sets the minimum patch; at equal variance a peaked kernel needs less habitat and also spreads faster, and demographic noise lifts the practical threshold, much less under a ceiling than under Beverton-Holt.
- Spatial sorting: the front that breeds its speed - a heritable dispersal trait accelerates a Gaussian front and widens the spread between replicates, and only the front to core trait cline separates it from a fat-tailed kernel.
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.
- 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.
- Particle MCMC for state space models - a particle filter likelihood inside Metropolis-Hastings samples the exact posterior, checked against a Kalman grid; the particle number sets mixing, and refreshing the current estimate is not exact.
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.
- Synthetic likelihood for noisy population dynamics - a Gaussian fitted to simulated summaries fits a chaotic Ricker where a skeleton fit cannot, but its interval for the noise is too narrow.
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.
- Dirichlet-multinomial models for read counts - a multinomial interval ignores the variation between samples and collapses as depth grows, the Dirichlet-multinomial caps the effective depth, and more samples help where more reads do not.
- Pseudocounts turn read depth into a result - a fixed 0.5 makes a sparse taxon’s log-ratio a function of library size, so unequal depth is reported as a group effect, while rarefying first or a negative binomial with a log depth offset holds the nominal rate.
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.
- Phylogeny in a multi-species meta-analysis - ignoring the tree shrinks the pooled interval by plain arithmetic; the correct model still undercovers, worst when its phylogenetic variance lands on zero, and a t on the tree’s effective species count covers on average, conservatively.
- Checking for publication bias - funnel plots, Egger’s regression and trim-and-fill, with the limits of each.
- Selection models for publication bias - fitting the selection mechanism by maximum likelihood instead of patching the funnel afterwards, and measuring how many studies it takes before that pays.
- 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.
- Meta-analysis of little-replicated experiments - with three bottles per arm the variance of a log response ratio is an estimate too: fixed-effect coverage falls as studies are added, tau-squared is manufactured, and Egger’s test fires on an honest literature.
- Inclusion criteria move the pooled effect - a screening rule that tracks a moderator shifts the pooled effect while the funnel plot, Egger’s test and I-squared stay quiet, and a sweep over defensible rules is wider than the noise alone.
- Checking published summary statistics - GRIM, standard deviation bounds and p values recomputed from a rounded t: a rounded number is a band, the checks go blind at larger samples, and one unreported exclusion flags an honest mean.
- Prediction intervals for a new site in meta-analysis - how often the prediction interval covers a new site’s effect: conservative with five studies, short of nominal from twenty on once tau-squared is often estimated as zero, and no estimator swap repairs it.
- PET-PEESE and publication bias under heterogeneity - the regression correction fails on a significance filter once studies differ by site, repairs reporting of the best of several responses on a common scale, and Egger’s test rarely asks for it.
- Year trends in effect sizes and the SE covariate - growing sample sizes plus a publication filter fake a decline with publication year; a standard error covariate removes it but costs much of the power to see a real decline, and the g-based standard error drags real declines towards zero.
- Correlations from gradients of different length - studies with one slope but gradients of different length give heterogeneous correlations and a spurious extent moderator; slopes, a log SD(x) moderator or a variance-adjusted range correction remove it.
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.
- Attrition in a field experiment: when pots die first - when a treatment changes which pots survive to harvest, report the survival gap with a trimming bound or an Imbens-Manski interval, not the survivor contrast alone.
- Culls set by this year’s count: a causal trap - a cull decided from the count makes that count both a reading of the mediator and the confounder of the next cull; iterated g-computation against weighting and a population model.
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.
- Dichotomising a continuous confounder - cutting a well measured confounder at its median leaves part of it unadjusted, and the leftover turns up in the coefficient you are reporting.
- 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.
- Summed radiocarbon dates: an honest, nearly blind test - a summed probability curve of radiocarbon dates is spiky even for a constant population; the Monte Carlo global test holds its level, but at 300 dates it misses most 300 year booms of 30 to 60 per cent.
- Tuning proxy records manufactures synchrony - shifting tie points within dating error makes independent records correlate, and at a lag one autocorrelation of 0.8 an effective sample size test still calls most tuned pairs significant.
- Pollen rate of change and uneven sample spacing - dividing a chord distance by uneven sample gaps puts the rate-of-change peak on the shortest gap; pooled time bins find a large turnover, one level per bin divided by its gap mostly does not.
- 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.
- Missing values in a predictor: why, not how many - with forty per cent of a predictor blank, the reason for the blank decides between deletion and multiple imputation, and the missingness test cannot tell which case you are in.
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.
- Weighted draws without replacement: sample() in R - sample(prob = w) picks one site at a time, so a Horvitz-Thompson mean on the intended probabilities is biased; systematic pps, Poisson and maximum-entropy draws are exact.
- Estimating an inclusion probability you already know - refitting a probability the design already fixed gives a more precise weighted mean, and the textbook variance then has to be corrected.
- Estimating plant cover with point intercepts - a hundred pins in one frame are not a hundred independent samples, and the nominal interval covers far less often than it claims.
- Leaf area from gap fraction: the segment length - the log of a mean gap fraction loses leaf area by a closed-form Jensen gap, short segments saturate, and with randomly placed clumps the best segment is shorter than a large clump and does not transfer between stands.
- Taylor’s power law and how many quadrats - the exponent linking variance to mean prices a survey in quadrats, and it moves with the quadrat size, so a published value does not carry across.
- Sequential sampling for pest decisions - a Wald plan decides after every plant whether to treat, but its lines contain the negative binomial k: a true k below the plan’s stops sooner and errs more, and Wald’s formulas undercount the plants it needs.
- Sampling until the standard error is small - stopping quadrats once the running standard error is a quarter of the mean misses the promised precision; at two per quadrat and above most of the miss is the price of a variable sample size, and Green’s stop line keeps its promise only while its exponent is right.
- Angle-count sampling for basal area - a prism samples trees in proportion to basal area, which sharpens basal area, costs precision on stem density, and the gap narrows in a clumped stand.
- Drone flushing pushes a survey count both ways - a lawnmower drone block counted from perfect images still comes out wrong: flushing recounts animals that fly into the not yet imaged strip and drives others off the block, so the edge, not the camera, sets the sign of the bias.
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.
- Reference sites and tolerance bounds - a percentile of ten reference sites gives most reference sets a false alarm rate above five per cent; a 95/95 tolerance bound holds it on normal scores at a cost in power, and on a left-skewed index it fails more often as sites are added.
- Carcass searches and fatality estimates - the Shoenfeld and Huso estimators assume a missed carcass is always or never found again and bracket the truth only when persistence is modelled right; the bracket is widest at frequent searches, and a two-search trial that estimates k keeps coverage near nominal.
- Biotic index scores and sorting effort - when sensitive families are rarer, ASPT-style averages drift with the number of animals sorted, so compare a site with references rarefied to the same count.
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.
- Detecting a die-off from carcass reports - a historical-limits alarm on weekly carcass reports: the variance model sets its real false alarm rate, and it helps detection only when the dispersion varies widely between weeks.
- CUSUM for die-offs when reporting effort persists - a CUSUM and a single-week historical-limits alarm on weekly carcass reports compared at matched false alarm rates: once reporting effort persists from week to week the single-week rule finds a fortnight die-off more often, while a CUSUM stays level or ahead for a die-off spread over four weeks.
- 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.
- Observer effects and the first-year dip - an observer term in a route count trend turns each novice first year into a spurious increase, one first-year indicator removes it, and a route-only trend stays nearly unbiased only when it starts with the survey.
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.
- Multilevel post-stratification of records - records leave the remote cells of the frame empty, dropping them biases the estimate, the plug-in interval fails at thin effort, and a cell random effect in mgcv fills the gaps.
- Revisits triggered by sightings in occupancy data - extra visits pulled in by recorded sightings leave occupancy unbiased, visits led by what locals know inflate it, the timing of the revisits rather than model fit is the clue, and a visit-count model repairs it only if it is right about empty sites.
- Year lists: cut at the recorder, not the site - a recorder who logs each species once a year biases occupancy with a sign set by how many sites they cover, cutting each site at its first report fails once recorders cover several sites, and cutting each year-lister at their first report anywhere repairs it.
- Flight-season shifts and false occupancy trends - a season sliding towards the edge of a fixed recording window reads as an occupancy decline; a year term on detection misses it once visits bunch, and a moving date curve recovers it.
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.
- Design weights in a stratified regression - when a slope needs the design weight, what it costs, and the weighted-unweighted gap as a test.
- Adaptive second-phase tows and the low mean - allocating phase two from phase one’s own variances pulls the pooled mean low and the interval short; allocating from variances the estimate will not reuse, such as last year’s, repairs it.
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.
- Harvest surveys and the late respondent - extrapolating across reminder waves removes a share of the respondent bias that the returned forms cannot reveal; a random follow-up of non-respondents is the only repair whose bias does not rest on the unseen, and at equal cost a fourth mailing ties it in two frames.
- 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.
- Data entry errors and what your checks catch - a range rule catches a third of keying errors and double entry nearly all, yet the errors each leaves behind decide how far the treatment contrast moves, and a higher catch rate can leave it further off.
- Spike tests on logger data delete real peaks - a running-median spike test is clean at a 5-minute interval but deletes about half the storm surge peaks at hourly logging, because surge width counted in readings, against the threshold, decides it by geometry.
- Instrument drift, run order and check standards - a sorted analyser run turns drift into a treatment effect, check standards leave their own reading error behind, and interspersed order removes both.
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.
- Back-transforming a log-scale model - the exponentiated line is the median, so a stand total comes out low, and the usual correction fails when the residuals are not lognormal.
- Ratio indices or ANCOVA for body size - dividing organ mass by body mass invents a site effect, even a reversed one, when fish differ in size; log-log ANCOVA holds its level, and a raw ANCOVA on the wrong curve fails with or without size overlap.
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.
- Species synchrony and community stability - the Loreau and de Mazancourt synchrony index splits community variability exactly, fixes the portfolio slope at one minus z over two, and a shared response makes more species less stable.
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.
- Net primary production from repeated harvests - the destructive-harvest route to production: summed increments grow with the number of harvest dates from noise alone, the peak misses turnover, and agreement with the truth is two errors cancelling.
- Chamber fluxes: linear or exponential fits - the soil chamber measurement: the linear slope’s bias is a formula, four syringe samples leave the exponential fit scattered with a long upper tail, and an AIC rule between the two mostly lands in between.
- Sap flow and the zero-flow baseline - the zero-flow baseline of a thermal dissipation probe turns night transpiration into lost water use and probe noise into extra, and averaging the predawn readings before taking a maximum removes most of the noise part.
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.
- Activation energy and the rising limb - why an Arrhenius slope fitted below the optimum still comes out low when the curve deactivates only at the hot end, by an amount set by the deactivation energy, and what a Sharpe-Schoolfield fit costs.
- Thermal death time and the ramping rate - why a ramp CTmax depends on the heating rate, and censored static assays for estimating z.
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.
- Patch-leaving rules and prey clumping - fixed number, fixed time or giving-up time for a forager that cannot see the patch: even prey favour the count, Poisson prey tie count and clock, and clumped prey hand the win to the giving-up time.
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.
This section and the animal model section below are also available as a free book, rewritten as one continuous text with a single notation: Quantitative Genetics from Scratch in R.
- 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.
- Evolutionary rescue and starting population size - adaptation racing decline in a branching process and an individual-based model, and why even odds of rescue need a Gomulkiewicz-Holt minimum of about 5 to 15 individuals, not one.
- Bateman gradients from genetic parentage - mates counted as the sires found among a female’s offspring build a gradient with no benefit of mating at small broods; half-genotyped broods behave as smaller broods, and counting their whole clutch as success halves that artefact without removing it.
- Nonlinear selection on BLUPs and on raw means - when assay counts follow lifespan, BLUPs fake disruptive selection and raw means fake stabilising selection; the squared BLUP plus PEV tests for curvature, and the first assay with moment variances sizes it.
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.
- Extra-pair paternity from parentage mismatches - a fixed mismatch rule turns genotyping error into extra-pair paternity as loci are added, extra-pair sires who are the social male’s brothers slip through, and the two repairs that fit the error rate each fail where their assumption does.
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.
- Observer agreement and Cohen’s kappa in R - the categorical side of reliability, and why kappa moves with class prevalence while the observers stay the same.
- Within- and between-individual effects in R - why a random intercept slope blends plasticity with among-individual differences, and how few records bias the between slope.
- Fitting a senescence model to individual records - selective disappearance flattens the ageing slope of an age plus random intercept model, the age at last reproduction or the mean age removes that once females still breeding at the end are handled, and with season effects only the curvature of ageing is identified, not the linear slope or the prime age.
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.
- Rock-paper-scissors needs local interaction - a well-mixed three-type cycle loses a type in about N/2 sweeps; small lattice neighbourhoods keep all three, and a batched update schedule can fake the ranking.
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
- Genotype-environment scans under shared ancestry - why a per-locus scan of allele frequency on environment flags half a neutral genome when the environment follows the axis of gene flow, and why the repair comes from the other loci rather than from the coordinates
- Heterozygosity-fitness correlations and power - how often a dozen microsatellites detect real inbreeding depression, the g2 estimator checked against a brute force version, and why a non-significant g2 does not clear the panel
- Runs of homozygosity and realised inbreeding - a linked genome with founder labels: why the pedigree coefficient is the worst of three measures of an individual’s inbreeding, and how much of a called run is not identical by descent
- Detecting sex-biased dispersal from genotypes - within-deme permutation tests of Fst and assignment indices by sex, why power is signal over noise rather than immigrant counts, and the offspring sample that shows nothing
- Genetic rescue: how many migrants, for how long - an inbred isolate with pedigree kinship and inbreeding depression: why a pulse of migrants only delays extinction, one a generation holds it only while it lasts, and how much migrant ancestry exceeds the neutral share
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
- Temporal Ne with overlapping generations: plan II bias - cohorts sampled a few years apart give negative estimates that the Waples 1989 plan II sampling term explains, adding the term back repairs adult samples, and uneven families in a large cohort need a correction of their own
- Mean kinship breeding in a captive population - ranking by mean kinship against equal family sizes, why it only pays when a few founders dominate, and what recording unknown sires as founders costs
- Related founders and marker kinship in a studbook - what assuming unrelated founders costs a mean kinship programme, and why SNP kinship needs allele frequencies from outside the founders
- Purging siblings before estimating Ne - removing reconstructed sibling pairs from a randomly sampled cohort raises the linkage disequilibrium estimate about four fold, while a random subsample of the same size stays near the truth
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.
- Siblings in an assignment baseline - full-sib families in the baseline make the exclusion test reject genuine residents, a null that simulates the family design repairs it, and leave-one-out self-assignment rises as the real accuracy falls.
- 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
- Patches cut by the edge of the map - what a square analysis window does to mean patch size, why dropping border patches is worse, and when the Miles-Lantuejoul weights work.
- Map accuracy and false fragmentation - at the same overall accuracy independent pixel errors multiply the patch count several times while errors that follow class boundaries inflate it far less, and a majority filter restores the count by deleting real small patches.
- Habitat amount versus fragmentation per se - a species that only tracks forest amount shows a false edge density effect under a straight-line amount term; a spline removes it, and landscape selection has to remove the curvature correlation, not the linear one.
- 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
- Downstream gene flow and the phantom dam - a headwater site holds less heterozygosity than the mainstem with no barrier on the river, so the standard above-versus-below test flags a dam that is not there, and the matched-position comparison repairs it
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.
- Two imperfect tests and no gold standard - the Hui-Walter model fitted by maximum likelihood, why test dependence leaves no trace in the fit, and how a small prevalence gap leaves sensitivity unbounded.
- Faecal egg count reduction tests at low counts - a McMaster factor of fifty usually makes a 99 per cent drug read 100 per cent, the paired bootstrap interval collapses, and a likelihood on the eggs actually counted does not.
- Infection rates from pooled vector samples - the minimum infection rate against the pool MLE, the bias from pooling within trap-nights, and why randomised pools still give a too-narrow interval for the vector population.
- 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.
- Density or frequency transmission in enclosures - the transmission exponent as a cloglog GLM across group sizes, why a narrow range of group sizes cannot decide the form, and why the interval has to be computed across enclosures.
- Snapshot prevalence and the phase of an epidemic - one PCR survey across sites reads each epidemic’s phase, so the density slope depends on survey date and introduction synchrony; serology from the same visit as the repair.
- 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.