Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Weighting data with IPW and mlogit

    Dear all,

    I intend to manually calculate inverse probability weights (IPW) in order to use them in a regression with a 3-value treatment, a binary dependent variable and a variable (let us call it 'indvar') I wish to test the effect of after having ascertained the effect of treatment. the command
    Code:
    teffects ipw
    with the
    Code:
    mlogit
    model allows me to test the effect of Treatment onto Outcome but does not allow me to add variables afterwards.

    So I have calculated the inverse probability weights as follows:
    Code:
    mlogit treatment covariates
    predict pscore, pr
    replace pscore=1/(1-pscore) if treatment==0
    replace pscore=1/pscore if treatment==1 | treatment==2
    
    logit depvar i.treatment indvar [pw=pscore]
    I believe it is the way to go as the values 1 and 2 for treatment regard the treated and 0 the controls. However, I haven't found explicit confirmation in literature. Can anyone confirms?
    Thank you very much for your useful comments,

    Best,

  • #2
    I think it really depends on what you are trying to estimate.
    See below an example that replicates the output from teffects when you have multivalued treatment
    Code:
    . use http://www.stata-press.com/data/r13/bdsianesi5, clear
    . teffects ipw  (wage ) (ed math7 read7 maed paed)
    
    
    ------------------------------------------------------------------------------
                 |               Robust
            wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    ATE          |
              ed |
    (O vs none)  |   1.522082   .2565685     5.93   0.000     1.019217    2.024947
    (A vs none)  |   2.143313   .2331868     9.19   0.000     1.686275    2.600351
    (H vs none)  |   4.233784   .3072937    13.78   0.000     3.631499    4.836069
    -------------+----------------------------------------------------------------
    POmean       |
              ed |
           none  |   6.138703   .1682554    36.48   0.000     5.808928    6.468477
    ------------------------------------------------------------------------------
    
    mlogit ed math7 read7 maed paed
    predict pr*
    
    gen ipw=1/pr1 if ed==0
    replace ipw=1/pr2 if ed==1
    replace ipw=1/pr3 if ed==2
    replace ipw=1/pr4 if ed==3
    
     
    
    reg wage i.ed [pw=ipw]
    
    ------------------------------------------------------------------------------
                 |               Robust
            wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              ed |
              O  |   1.522082   .2598177     5.86   0.000     1.012484    2.031681
              A  |   2.143313   .2401388     8.93   0.000     1.672312    2.614314
              H  |   4.233784   .3114486    13.59   0.000     3.622918     4.84465
                 |
           _cons |   6.138703   .1697105    36.17   0.000     5.805838    6.471568
    ------------------------------------------------------------------------------
    The standard errors for the replication are not quite correct, but otherwise, that is what IPW does.
    HTH

    Comment


    • #3
      Dear Fernando,
      Thank you so much for that comment, it seems all clearer now, I don't know how I didn't think of that... Thanks again and best wishes

      Comment


      • #4
        Dear Fernando,

        I am very happy to see how you replicate the what teffects ipw do using mlogit and reg.

        Do you know how to calculate the odds ratio if my outcome is binary, i.e. wage is binary in your example "teffects ipw (wage ) (ed math7 read7 maed paed)"?



        Comment


        • #5
          Same thing
          unless you use logit for the outcome

          Comment


          • #6
            Ya: To get the odds ratio, I think you'll have to do it "by hand."

            Code:
            mlogit treat x1 ... xK
            predict pr*
            gen ipw=1/pr1 if treat==0
            replace ipw=1/pr2 if treat==1
            replace ipw=1/pr3 if treat==2
            replace ipw=1/pr4 if treat==3
            sum x1 
            gen x1_dm = x1 - r(mean)
            sum x2 
            gen x2_dm = x2 - r(mean)
            ...
            sum xK 
            gen xK_dm = xK - r(mean)
            gen treat1 = treat == 1
            gen treat2 = treat == 2
            gen treat3 = treat == 3
            logit y treat1 treat2 treat3 x1 x2 ... xK  i.treat1#c.x1_dm i.treat2#c.x1_dm i.treat3#c.x1_dm ... i.treat1#c.xK_dm i.treat2#c.xK_dm i.treat3#c.xK_dm [pweight = ipw]
            The coefficients on treat1, treat2, treat3 are the effects on the log odds relative to the base treatment (zero) (evaluated at the average values of the covariates, so like at ATE). The standard errors won't be correct, but they should be conservative.

            Comment


            • #7
              Dear Jeff Wooldridge

              Thank you so much for your clear reply. It works for me.


              Comment

              Working...
              X