Estimate response functions of agricultural production following a weather shock, using Local Projections as in Chapter 7, keeping data from years from 2001 to 2014 instead of data from 2001 to 2015 (hence removing the last year of observations).
This chapter uses Jordà (2005) Local Projection framework to measure how sensitive agricultural output is to exogenous changes in the weather. It complements Chapter 7 and removes the last year of observations from the sample.
In the raw data from the Ministry of Agriculture, observations are provided on a monthly basis until 2015. For 2016, the data are available only on a quarterly basis. Each file from 2001 to 2015 reports both the production value for the current year and a revised version for the previous year. In our main analysis, we used the revised production data until 2015. Since no revised values were available for 2016, we used the unrevised 2015 data in our sample. In this chapter, we consider estimating the regressions without the unrevised production data, focusing on the data spanning from 2001 to 2014 instead of 2001 to 2015.
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(fastDummies)
Thank you for using fastDummies!
To acknowledge our work, please cite the package:
Kaplan, J. & Schlegel, B. (2023). fastDummies: Fast Creation of Dummy (Binary) Columns and Rows from Categorical Variables. Version 1.7.1. URL: https://github.com/jacobkap/fastDummies, https://jacobkap.github.io/fastDummies/.
# Functions useful to shape the data for local projectionssource("../weatherperu/R/format_data.R")# Load function in utilssource("../weatherperu/R/utils.R")# Load detrending functionssource("../weatherperu/R/detrending.R")
19.1 Linear Local Projections
In this section, we focus on estimating the Local Projections (Jordà 2005) to quantify the impact of weather on agricultural production. We use panel data, similar to the approach used in the study by Acevedo et al. (2020), and independently estimate models for each specific crop.
For a particular crop denoted as \(c\), the model can be expressed as follows: \[
\begin{aligned}
\underbrace{y_{c,i,{\color{wongGold}t+h}}}_{\text{Production}} = & {\color{wongOrange}\beta_{c,{\color{wongGold}h}}^{{\color{wongPurple}T}}} {\color{wongPurple}{T_{i,{\color{wongGold}t}}}} + {\color{wongOrange}\beta_{c,{\color{wongGold}h}}^{{\color{wongPurple}P}}} {\color{wongPurple}P_{i,{\color{wongGold}t}}}\\
&+\gamma_{c,i,h}\underbrace{X_{t}}_{\text{controls}} + \underbrace{\zeta_{c,i,h} \text{Trend}_{t} + \eta_{c,i,h} \text{Trend}^2_{t}}_{\text{regional monthly trend}} + \varepsilon_{c,i,t+h}
\end{aligned}
\tag{19.1}\]
Here, \(i\) represents the region, \(t\) represents the time, and \(h\) represents the horizon. The primary focus lies on estimating the coefficients associated with temperature and precipitation for different time horizons\(\color{wongGold}h=\{0,1,...,T_{c}\}\)
Note that we allow a crop regional monthly specific quadratic trend to be estimated.
19.1.1 Functions
The estimation functions presented in Chapter 7.1.1 can be sourced.
source("../weatherperu/R/estimations.R")
19.1.2 Estimation
To loop over the different crops, we can use the map() function. This function enables us to apply the estimate_linear_lp() function to each crop iteratively, facilitating the estimation process.
We can visualize the Impulse Response Functions (IRFs) by plotting the estimated coefficients associated with the weather variables. These coefficients represent the impact of weather on agricultural production and can provide valuable insights into the dynamics of the system. By plotting the IRFs, we can gain a better understanding of the relationship between weather variables and the response of agricultural production over time.
Acevedo, Sebastian, Mico Mrkaic, Natalija Novta, Evgenia Pugacheva, and Petia Topalova. 2020. “The Effects of Weather Shocks on Economic Activity: What Are the Channels of Impact?”Journal of Macroeconomics 65: 103207.
Jordà, Òscar. 2005. “Estimation and Inference of Impulse Responses by Local Projections.”American Economic Review 95 (1): 161–82. https://doi.org/10.1257/0002828053828518.