Let's say there's
a command we're using to do some causal effect estimation. We run the command, and afterwards, it produces a pretty graph that's meant to be illustrative and informative. Well if you're at all like me, you like to edit your graphs in detail. Sure, I could go into the ado file and make changes, but what if I want to exercise total control over how the graph looks, or at least, more control than the current command offers? Is it possible to add two-way plot options, to a graph option for an existing command? I have no idea, since I've never written a graphics command before, so
PRESUMABLY Stata Corp has some standardized way to to this.
Lets play with some real data, shall we?
Code:
import delim "https://raw.githubusercontent.com/danilofreire/homicides-sp-synth/master/data/df.csv", clear
cap which synth
if _rc { // installs the synth command if you don't have it
ssc install synth, replace all
*Abadie's synthetic control estimator
}
xtset code year, y // declares it panel data
loc int_date = 1999
rename proportionextremepoverty expov
cls
g treated = 1 if code == 35 & year >= 1999
replace treated = 0 if treated == .
cls
synth homiciderates homiciderates stategdpcapita ///
stategdpgrowthpercent ///
populationextremepovertyimp ///
yearsschoolingimp ///
giniimp ///
expov ///
populationprojectionln, ///
trunit(35) ///
trperiod(1999) ///
fig //
Okay so far, we've gotten some data from a
previously published paper and ran one of his specifications. We've also made a graph, displaying the usual stuff
synth gives us in this instance. What if I wanted to add a title to this graph, though? What if I wanted to add the equivalent of synth ... fig(ti("This is a graph title")? Or what if I wanted to change the graph scheme to something different than what the authors intended like synth ... fig(scheme(yourscheme)? How might I edit this command for my own purposes, such that I don't always need to make a separate graph 10 lines below my estimation command because the graph that came with the command isn't good enough for me?
I imagine I'll need to do some minor surgery on the ado file itself; how might I go about this? I know how to access the ado file (I use
adoedit to change ado files on the fly), but what syntactic modifications would I need to make to have it do what I want? For context, the plot option is around line 656 in the ado file for synth, where the figure option is specified.
0 Response to Adding 2-Way Plot Options to User Written Commands
Post a Comment