Hi. As in the previous post,
Hi All,
In case anyone viewing this thread is interested, here's the code to do what Navid with a few additions to display both graphs side-by-side with the y- axes having common scales.
sysuse auto, clear
psmatch2 foreign mpg, out(price)
// compare _pscores before matching & save graph to disk
twoway (kdensity _pscore if _treated==1) (kdensity _pscore if _treated==0, ///
lpattern(dash)), legend( label( 1 "treated") label( 2 "control" ) ) ///
xtitle("propensity scores BEFORE matching") saving(before, replace)
// compare _pscores *after* matching & save graph to disk
gen match=_n1
replace match=_id if match==.
duplicates tag match, gen(dup)
twoway (kdensity _pscore if _treated==1) (kdensity _pscore if _treated==0 ///
& dup>0, lpattern(dash)), legend( label( 1 "treated") label( 2 "control" )) ///
xtitle("propensity scores AFTER matching") saving(after, replace)
// combine these two graphs that were saved to disk
// put both graphs on y axes with common scales
graph combine before.gph after.gph, ycommon
Richard
In case anyone viewing this thread is interested, here's the code to do what Navid with a few additions to display both graphs side-by-side with the y- axes having common scales.
sysuse auto, clear
psmatch2 foreign mpg, out(price)
// compare _pscores before matching & save graph to disk
twoway (kdensity _pscore if _treated==1) (kdensity _pscore if _treated==0, ///
lpattern(dash)), legend( label( 1 "treated") label( 2 "control" ) ) ///
xtitle("propensity scores BEFORE matching") saving(before, replace)
// compare _pscores *after* matching & save graph to disk
gen match=_n1
replace match=_id if match==.
duplicates tag match, gen(dup)
twoway (kdensity _pscore if _treated==1) (kdensity _pscore if _treated==0 ///
& dup>0, lpattern(dash)), legend( label( 1 "treated") label( 2 "control" )) ///
xtitle("propensity scores AFTER matching") saving(after, replace)
// combine these two graphs that were saved to disk
// put both graphs on y axes with common scales
graph combine before.gph after.gph, ycommon
Richard
Code:
replace _treat =1 if _treat ==1 & _weight != . replace _treat =0 if _treat ==0 & dup >0
Thank you in advance.
0 Response to Changes in Control/Treatment groups after PSM
Post a Comment