01/05/2026
๐ Endogeneity Testing Across Multiple Outcome Variables (Stata)
Iโve recently run a systematic endogeneity check across all my key dependent variables using IV regression. The idea is to test whether fertility_rate is endogenous in explaining different wellbeing outcomes.
๐ Outcome variables used:
dv_phy
dv_sex
Emotional_Index
dv_overall_index_pct
โ๏ธ Stata Code:
*========================================
* ENDOGENEITY TESTS FOR ALL DEPENDENT VARIABLES
*========================================
global outcomes dv_phy dv_sex Emotional_Index dv_overall_index_pct
foreach y of global outcomes {
ivreg2 `y' $controls (fertility_rate = $IV_both), ///
endog(fertility_rate) cluster(cluster)
outreg2 using "$Results/Endogeneity_All_Outcomes.xls", ///
append ctitle("Endogeneity Test: `y'")
}
๐ What this does:
Runs IV regression for each outcome variable in a loop
Tests whether fertility_rate is endogenous
Uses clustered standard errors
Stores results in a single Excel file for comparison
This approach keeps the analysis clean, scalable, and consistent across multiple outcomes.
If anyone is doing similar multi-outcome IV work, this loop-based structure is very efficient.