Home / Projects / Climate and agriculture

Climate change and global agriculture: which adaptation strategies work, and where

R Markdown analysis on GitHub

Data
10,000 synthetic records, 1990-202415 features; checked against EDGAR, NOAA and FAOSTAT patterns
Outcomes
Crop yield, economic impacteconomic impact in USD million
Strategies compared
Fourcrop rotation, water management, drought-resistant crops, organic farming

In short. The practical question: which adaptation strategy (crop rotation, water management, drought-resistant crops or organic farming) works best for which crop and region? The project answers it in steps: describe how climate and inputs relate to yield, predict yield, then estimate each strategy's effect separately for each crop and region. The data is synthetic, so this demonstrates the method, not findings about real farms.

01Question

Climate change threatens crop yields, but farmers respond with different adaptation strategies, and whether a strategy works probably depends on the crop and the region. The project moves from describing the relationship between climate, inputs and yield, to predicting yield, to asking which strategy is most effective in which context.

The dataset is synthetic, and the report says so. As a check, its trends were compared with authoritative sources: CO2 levels with EDGAR, temperature patterns with NOAA climate records, and yield patterns with FAOSTAT. The overall patterns were similar. Conclusions are therefore about the method on this dataset, not findings about real farms.

The dataset at a glance
Observations10,000
Features15
Period1990-2024
Structureyearly records by crop, region and country
Rows removed19 (about 0.19%), impossible negative inputs
Fertilizer vs yieldcorrelation 0.73
Yield vs economic impactcorrelation 0.73

02Method

  • Preparation. Removed 19 rows (about 0.19% of the 10,000 observations) with physically impossible negative pesticide and fertilizer values, and grouped countries into climate zones to reduce the cardinality of the country variable.
  • Exploration. Fertilizer use and yield correlate at 0.73, as do yield and economic impact, while climate variables alone show only weak linear correlation with yield. That pointed to non-linear effects and justified a GAM.
  • Inference. Linear mixed-effects models (lme4), with random intercepts for crop and for region nested in country, because observations are hierarchical. Generalized additive models (mgcv) to show non-linear effects of temperature, fertilizer, pesticide, CO2, irrigation and soil.
  • Prediction. Random Forest in tidymodels with an 80/20 split and 5-fold cross-validation for tuning, checked with residual plots and variable importance.
  • Causal analysis. Because strategies are not randomly assigned, multinomial propensity-score weighting (with robust standard errors) estimates average treatment effects, and causal forests (grf) estimate how effects differ by crop and region.
Analysis workflow Five steps: prepare the data, explore it, explain it with mixed-effects and additive models, predict yield with a Random Forest, and compare adaptation strategies with propensity-score weighting and causal forests. 1 Prepare19 impossible rows removed, countries groupedinto climate zones 2 Explorefertilizer and yield r = 0.73; climate effectsweakly linear, so smooth terms are needed 3 Explainmixed-effects models (crop, region in country)additive models for non-linear effects 4 PredictRandom Forest, 80/20 split, 5-fold tuning,residual and importance checks 5 Compare strategiespropensity-score weighting, then causal forests
The analysis workflow, following CRISP-DM from preparation to causal effects.

03What this shows

The project is a complete workflow from data cleaning to heterogeneous treatment effects, with each modelling choice justified in the analysis: why mixed effects, why GAMs, why weighting. Treatment-effect estimates from observational data depend on unconfoundedness assumptions that cannot be verified here, and the data is synthetic, so I present this as a demonstration of method rather than as evidence about which strategy to adopt.

Code: R Markdown analysis on GitHub. The dataset file is not included, and the written report is not published.

Why each method was chosen
SituationMethod
Observations nested in crops, regions and countriesMixed-effects models, to respect the hierarchy and give valid standard errors
Climate effects not linearGeneralized additive models, which fit smooth curves
Strategies not randomly assignedPropensity-score weighting, to balance confounders
Effects may differ by crop and regionCausal forests, for heterogeneous treatment effects