Published December 11, 2025 | Version 2.0.0
Computational notebook Open

Data and code associated with: Towards causal predictions of site-specific management effects in applied ecology

  • 1. ROR icon University of Reading
  • 2. ROR icon Swedish University of Agricultural Sciences
  • 3. ROR icon UK Centre for Ecology & Hydrology

Description

This repository contains the code and data for our preprint:

E. E. Jackson, T. Snäll, E. Gardner, J. M. Bullock & R. Spake (2025). Towards causal predictions of site-specific management effects in applied ecology. EcoEvoRxiv. DOI: 10.32942/X2KK95

Article abstract:

With limited resources and the urgent need to reverse biodiversity loss, conservation efforts must be targeted to where they will be most effective. Targeting actions necessitates new approaches to causal prediction of sited-level responses to alternative interventions. We present the first application of ‘meta-learner algorithms’ to predict ‘individual treatment effects’ (ITEs) representing the effects of site-level management actions. We compare the performance of three algorithms that differ in how they handle selection biases typical to observational data: S-, T-, and X-Learners, across 4,050 virtual studies predicting the effect of forest management on soil carbon, the ITEs. The X-Learner, an algorithm which adjusts for selection bias, consistently yielded the most accurate ITE predictions across studies varying in sample size and imbalanced sample sizes of treatment and control groups. Our study illustrates how ecologists can begin to select and apply causal prediction methods to inform targeted conservation action for ecological systems, and makes suggestions for further road-testing of these approaches.

Contents:

code/

The code/ directory contains these subdirectories:

  • scripts/ contains action scripts, i.e. all the code for cleaning, combining, and analysing the data. All paths in the scripts are relative to the root directory (where the .Rproj file lives). Each .R script has a summary at the top of what it does. The scripts are numbered in the order in which they would typically be run.
  • functions/ contains R functions which are called by scripts in the code/scripts/ directory. Note that functions were designed to be used only within this project.
  • notebooks/ contains .Rmd files that were used for exploratory analysis and note-taking. Notebooks are not intended to be reproducible but the .md files can be viewed as rendered html (with output) on GitHub.

data/

The original data is stored in the data/raw/ subdirectory. Any data that is produced using code is stored in data/derived/

output/

The output/ directory contains the subdirectory figures/, which contains the figures used in the paper.

docs/

The docs/ directory contains the data dictionary / metadata. 

Usage

To reproduce results and figures from this project in the RStudio IDE, first open the .Rproj file and call renv::restore() to restore the project's R package library. Then, run the .R scripts in code/scripts/ in the order in which they are labelled, starting from 02_identify-test-plots.R. Note that the first two scripts which clean and filter the data are for reference only, since we will be providing the cleaned data in this repository.

Two of the scripts (03_get-ite-predictions.R and 10_plot-all-true-vs-predictions.R) require a lot of time (~12hrs) and memory (~50GB) to run. It is recommended to run them on a High-Performance Computing cluster, or else run fewer simulations ("virtual studies").

NetCDF (required by the R package {ncdf4}) is needed to read the CRU TS climate data.

Files

tree-2.0.0.zip

Files (583.8 MB)

Name Size Download all
md5:c62bc1a4a3dcbbeac626c898c4d9acfb
583.8 MB Preview Download

Additional details

Related works

Is supplement to
Preprint: 10.32942/X2KK95 (DOI)

Funding

Natural Environment Research Council
Transferable Ecology for a changing world (TREE) NE/X009998/1

Software

Repository URL
https://github.com/ee-jackson/tree/tree/main
Programming language
R