Home / Projects / Climate and agriculture
Climate change and global agriculture: which adaptation strategies work, and where
- 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.
| Observations | 10,000 |
| Features | 15 |
| Period | 1990-2024 |
| Structure | yearly records by crop, region and country |
| Rows removed | 19 (about 0.19%), impossible negative inputs |
| Fertilizer vs yield | correlation 0.73 |
| Yield vs economic impact | correlation 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.
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.
| Situation | Method |
|---|---|
| Observations nested in crops, regions and countries | Mixed-effects models, to respect the hierarchy and give valid standard errors |
| Climate effects not linear | Generalized additive models, which fit smooth curves |
| Strategies not randomly assigned | Propensity-score weighting, to balance confounders |
| Effects may differ by crop and region | Causal forests, for heterogeneous treatment effects |