Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st:propensity score matchign graph


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st:propensity score matchign graph
Date   Thu, 28 Jun 2007 10:54:58 -0400

Celia Patricia Vera <[email protected]>:
In my previous msg, there were a couple of missing pieces, inserted in
situ below. I also did all the graphs using mpg as pscore, so the
units are integers greater than one, not proportions.  You may want
to:
gen pscore=_pscore*100
before you run any of my code, and/or adapt the code to your units as
appropriate.  Here's one more or less complete example illustrating
histogram, rectangle and epanechnikov kernel estimates of density:

clear
sysuse auto
qui psmatch2 for mpg, out(pr)
gen pscore=_pscore*100
twoway__histogram_gen psc if for==0, w(1) gen(f0 x0)
twoway__histogram_gen psc if for==1, w(1) gen(f1 x1)
line f0 x0 || line f1 x1, leg(lab(1 "Untreated") lab(2 "Treated")) name(h)
su pscore, meanonly
loc lb=floor(r(min))
loc ub=ceil(r(max))
loc r=`ub'-`lb'
if _N<`r' set obs `r'
g x=_n-1+`lb'
replace x=. if x>`ub'
kdens pscore if for==0, at(x) gen(t0) nogr
kdens pscore if for==1, at(x) gen(t1) nogr
line t0 t1 x, leg(lab(1 "Untreated") lab(2 "Treated")) name(e)
forv i=0/1 {
kdens pscore if for==`i', at(x) gen(r`i') k(r) a(1) nogr
replace r`i'=. if r`i'==0
}
line r0 r1 x, leg(lab(1 "Untreated") lab(2 "Treated")) name(r)


On 6/28/07, Austin Nichols <[email protected]> wrote:
Celia Patricia Vera <[email protected]>:
You want to compare densities of variable pscore for two populations
defined by treatment==1 and treatment==0. This can be done with
-dotplot- or -tw hist- if many observations have the same value (as
frequently happens when using a number of categorical values in PS
matching), e.g.

sysuse auto, clear
dotplot mpg, over(for)
tw hist mpg, by(for)
twoway__histogram_gen mpg if for==0, w(1) gen(f0 x0)
twoway__histogram_gen mpg if for==1, w(1) gen(f1 x1)
line f0 x0 || line f1 x1, leg(lab(1 "Untreated") lab(2 "Treated"))

(taking mpg as pscore and for as treatment) but a more general
approach is to use -kdensity- or -kdens- (avail via -ssc inst kdens-)
like so:
* next 3 lines define the support over which to graph
su mpg
g x=_n-1+floor(r(min))
replace x=. if x>ceil(r(max))
kdens mpg if for==0, at(x) gen(t0) nogr
kdens mpg if for==1, at(x) gen(t1) nogr
line t0 t1 x, leg(lab(1 "Untreated") lab(2 "Treated"))

where there are a host of options for -kdens- that may change your results, e.g.

kdens mpg if for==0, at(x) gen(u0) nogr bw(o) k(t)
kdens mpg if for==1, at(x) gen(u1) nogr bw(o) k(t)
line t0 u0 t1 u1 x


On 6/28/07, Celia Patricia Vera <[email protected]> wrote:
> I want to graph the density function  for the
> propensity score for both treated and no treated (in
> the same graph) in order to see the overlapping
> regions.
> I do not find the way to do that.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index