Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: pweights, propensity scores

 From William Buchanan To "statalist@hsphsun2.harvard.edu" Subject Re: st: pweights, propensity scores Date Fri, 18 Jan 2013 07:10:52 -0800

```Hi Paul,

If you go to the UCLA website for the book Methods Matter (Murnane and Willett, 2011), there are a few different approaches for propensity score analysis. The approach suggested there uses analytical weights.  You could also check out several user-written packages that provide a much more robust set of tools for PSA (e.g., different matching algorithms, diagnostics of the matching, etc...)

HTH,
Billy

Murnane, R., & Willett, J. (2011). Methods matter: improving causal inference in educational and social science research. New York, NY: Oxford University Press

Sent from my iPhone

On Jan 18, 2013, at 6:17, Paul <paulburk314@gmail.com> wrote:

>
> There seem to be a few problems with that solution though: I don't wan
> aweights, which stata is assuming with the [w=w].  This shouldn't
> matter for the point estimates though, so it's still a useful
> exercise.  Also, using sum over treated and untreated seperately can't
> give me the formula I want, since I need N^-1 in front of the summand.
> Your solution does at least give me insight into what pweight is
> doing in the reg command, which, contrary to the stata journal article
> I cite below, seems incorrect.
>
> Thanks.
>
> On Fri, Jan 18, 2013 at 3:59 AM, Christophe Kolodziejczyk
> <ck.statalist@gmail.com> wrote:
>> Hi Paul
>> I think you have to compute the weighted mean separately for the
>> different samples, i.e the first weighted sum should be divided by the
>> number of treated and the second sum should be divided by the number
>> of controls.
>>
>>
>> logit treatment X
>> predict p
>>
>> gen w = cond(treatment,1/p,1/(1-p))
>>
>> reg y treatment [w=w]
>>
>> sum y if treatment [w=w]
>> local m1 = `r(mean)'
>> sum y if !treatment [w=w]
>> local m0 = `r(mean)'
>>
>> di "ATE = " `=`m1'-`m0''
>>
>>
>>
>> Best
>> Christophe
>>
>>
>> 2013/1/17 Paul <paulburk314@gmail.com>:
>>> Hi all,
>>>
>>> I'm using propensity scores to estimate treatment effects, where
>>> treatment is exogenous conditional on the propensity score. I'm using
>>> an estimator from Wooldridge's 2010 text book, which is also discussed
>>> in The Stata Journal (2008) 8, Number 3, pp. 334–353.
>>>
>>> Specifically, the treatment effect is estimated using (1/N) sum
>>> (T*Y/p) - (1/N) sum ((1-T)*Y/(1-p).
>>>
>>> According to the Stata Journal article, this can be estimated using a
>>> regression with pweights equal to the "inverse of the treatment
>>> probability deﬁned using the
>>> propensity score." However, when I use just the sum of the weighted
>>> variables, I get a different answer from the regression result.  I'm
>>> not terribly familiar with pweights, so I could be making some dumb
>>> mistake.
>>>
>>> Below is my code.  Does anyone know what I'm doing wrong, or what the
>>> correct way to implement this method is?
>>>
>>> Thanks,
>>> Paul
>>>
>>> /* Regression using pweights */
>>> gen ipw=1/p_x if treated==1
>>> replace ipw=1/(1-p_x) if treated==0
>>>
>>> reg y treated [pweight=ipw]
>>>
>>> /* IPTW one variable */
>>> gen w1=((treated-p_x)/(p_x*(1-p_x)))
>>> gen w1_y=w1 *y
>>>
>>> sum w1_y
>>>
>>> /* IPTW two variables */
>>> gen w2a_y=y*treated/p_x
>>> gen w2b_y=y*(1-treated)/(1-p_x)
>>>
>>> foreach type in a b{
>>>  sum w2`type'_y
>>>  local mean_w2`type' =r(mean)
>>> }
>>>
>>> di `mean_w2a'-`mean_w2b'
>>>
>>> /* IPTW two variables weights sum to one */
>>> bysort treated: egen w_ipw=total(ipw)
>>> gen w3a_y=(1/w_ipw)*y*treated/p_x
>>> gen w3b_y=(1/w_ipw)*y*(1-treated)/(1-p_x)
>>>
>>> foreach type in a b{
>>>  sum w3`type'_y
>>>  local mean_w3`type' =r(mean)
>>> }
>>>
>>> di `mean_w3a'-`mean_w3b'
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>>
>> --
>> Christophe Kolodziejczyk
>> Research Fellow
>>
>> AKF, Anvendt KommunalForskning
>> Danish Institute of Governmental Research
>> DK-1150 København K
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```