Event Plot with `coefplot` (Event Studies)
In this exercise, you’ll graph the results of the event study you estimated in the previous exercise so we can visualize the dynamic effect of STRV seed adoption on crop yields over time.
- You already estimated the robust event study in the previous exercise using
eventstudyinteract. Re-run that exacteventstudyinteractcommand (without theerepostpart) to ensure the model results are fresh in Stata’s memory. - Extract the interaction-weighted coefficients into a matrix: use
matrix C = e(b_iw)to grab the point estimates from the stored results. - The variance-covariance matrix
e(V_iw)contains the variances on its diagonal. To get standard errors, you need the square root of those diagonal elements. Usematato do this in one line:mata st_matrix( "A", sqrt( diagonal( st_matrix ("e(V_iw)") ) ) ). - Stack the standard errors below the coefficients:
matrix C = C \ A'. The backslash (\) stacks matrices vertically, andA'transposesAfrom a column vector to a row vector so it aligns withC. Now row 1 ofCis the coefficients and row 2 is the standard errors. - Print the matrix to verify:
matrix list C. You should see one row of point estimates and one row of standard errors, with columns named after your lead and lag dummies.
1. How many columns does your matrix C have? Does this match the number of lead and lag dummies you created?
2.Now use coefplot to plot directly from the matrix C. Build the plot with the following options:
- Source the coefficients from row 1 of
Cusingmatrix(C[1])and pair them with standard errors from row 2 usingse(C[2]). - Set the graph region background to white with
graphregion(fcolor(white)). - Label the x-axis “Event years” using
xtitle()withsize(medlarge). - Orient the plot vertically and include the omitted period as a zero with the
verticalandomittedoptions. - Use square markers (
msymbol(s)), colored black (mc(black)) with white fill (mfcolor(white)). - Add a horizontal reference line at zero using
yline(0)with thin black styling. - Connect the points with thick black lines using
recast(connected),lw(thick), andlc(black). - Display the confidence intervals as dashed lines using
ciopts(recast(rline) lw(thin) lc(black) lp(dash)). - Add a vertical treatment reference line at position 16 (where
g_1would be — the last pre-treatment period) usingxline()in red. - Suppress the grid with
ylabel(, angle(0) nogrid)and keep only the lead/lag coefficients withkeep(g_* g*). - Clean up the coefficient labels using
rename(g_* = "-" g* = "")so leads show as negative numbers and lags as positive. - Set the y-axis title to “Median EVI” and manually label the x-axis tick marks at informative intervals (e.g., positions 02, 07, 12, 16, 21, 25 labeled as “-15”, “-10”, “-5”, “0”, “5”, “10”).
- Export the plot and import it into your Overleaf file.
3. Do the pre-treatment coefficients hover near zero, consistent with parallel trends? After adoption, does the effect of STRV seed on evi_med appear to grow over time, or is it immediate and constant?