I'm working with dyadic panel data and estimating a Poisson Pseudo Maximum Likelihood (PPML) gravity model. Two variables I suspect to be endogenous (let's call them var1 and var2) are initially regressed on several institutional predictors using OLS. I then use the residuals in my gravity model.
After that, I construct lagged versions of the residuals to serve as instruments. Here’s the general structure of my code (simplified and anonymized):
# Step 1: Regress var1 and var2 on instruments
ols_1