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

  • regression after teffects psmatch ..., nn(3)

    Dear Statalist members,

    I have the following problem and cant find an answer by myself: I want to run a propensity score weighted regression by using the command teffects psmatch to estimate the propensity scores.
    For the default value of nearest neighbor = 1 it is no problem since the help of the guide But if I want to estimate the propensity scores with nearest neighbor values of 3 or 5 I dont know how to adjust the algorithm:

    teffects psmatch (y) (treatment x x x x x x), atet gen(match) nn(3 or 5)

    predict ps0 ps1, ps

    predict y0 y1, po
    *Because observation 1 is in the control group, y0 contains its observed value of y. y1 is the observed value of y for observation X's match, observation XX

    predict te
    *The treatment effect is simply the difference between y1 and y0. You could calculate the ATE yourself (but emphatically not its standard error) with:

    sum te

    *and the ATET with:

    sum te if treatment==1

    *regression preparation

    gen ob=_n //store the observation numbers for future use
    save fulldata,replace // save the complete data set

    keep if treatment // keep just the treated group
    keep match1 // keep just the match1 variable (the observation numbers of their matches)
    bysort match1: gen weight=_N // count how many times each control observation is a match
    by match1: keep if _n==1 // keep just one row per control observation
    ren match1 ob //rename for merging purposes

    merge 1:m ob using fulldata // merge back into the full data
    replace weight=1 if gdum // set weight to 1 for treated observations

    regress y treatment x x x xx x x x x z z z [fweight=weight], robust

    so how must the middle part be modified so that the weights are adjusted to the nn(3 or 5) option?

    Thank you very much!



  • #2

    Hello Kurt I have the same problem now I do not know how to adjust the weight in case of using more than one nearest neighbor, please could you help me if you have an idea ??thank you


    • #3
      Hi Dano Hano Kurt Wichtelsacker I have run in to the same problem, did you manage to solve it?


      • #4
        set obs 1000
        g y = runiform()*10
        g treatment = rbinomial(1, .66)
        for A in num 1/5 : g xA = rbeta(1,100)
        su *
        regress y i.treatment x*  , robust
        est sto before
        local matches =3 //change this to number of nn 
        g obs = _n
        teffects psmatch (y) (treatment x*), atet gen(match) nn(`matches') 
        teffects overlap
        predict ps0 ps1, ps
        predict y0 y1, po
        predict te
        sum te
        sum te if treatment==1
        sort obs
        l y* treatment obs match* ps* te in 1/5, noobs clean
        l y* treatment obs   match* ps* te  if inlist(24, obs, match1, match2, match3), noobs clean
        sa fulldata,replace 
        forval n = 1/`matches' {
        keep if treatment  
        keep match`n'  
        bysort match`n': gen weight=_N  
        by match`n': keep if _n==1 
        rename match`n' obs
        merge 1:m obs using fulldata.dta 
        assert _m!=1
        cap drop _m
        replace weight=1 if treatment ==1   
        tabstat weight ps* , by(treatment)
        *take a look
        tw   (scatter y ps1 if treatment ==0 )  (scatter y ps1 if treatment==1)  (lfit y ps1 if treatment ==0 , lwidth(thick) )  (lfit y ps1 if treatment==1, lwidth(thick))
        cap which binscatter
        if _rc   ssc install binscatter, replace //from SSC if not already installed
        binscatter y ps1, by(treatment)  
        qui regress y i.treatment x* [fweight=weight], robust
        est sto after
        est table before after, star
        Eric A. Booth
        Senior Research Scientist, Gibson Consulting Group |


        • #5
          Could you please explain me what are the main goals of doing the following and how should I interpret them when comparing with teffects psmatch...?

           predict ps0 ps1, ps  predict y0 y1, po  predict te  sum te

          And what about the code "teffects overlap"?

          Thank you in advance.