Announcement

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

  • Propensity Score Matching

    Hi everyone,

    I am still figuring out PSM for my study.I am having trouble in the first step matching. When i graph the histogram for before and after matching there is not much of a difference in the two. I am not sure if it is because the confounding variables i have selected are weak or it is because there is something wrong in the way my codes are formed. Could it be that the dataset i have the treated and control groups are already balanced? but this is a cross sectional data not RCT. I am desperately looking for some help and clarity so i can move on to evaluating ATT. Thank you so much for all the help.

    in STEP 1: i use the probit
    Code:
    probit $TREAT $HH $GEO $HH_RESP
    predict pre_probit, p
    in Step 2 : i use psmatch2

    Code:
    psmatch2 $TREAT $HH $GEO $HH_RESP
    sum _pscore
    sum _pscore if $TREAT ==1
    sum _pscore if $TREAT ==0
    psgraph

    in Step 3: i make a two way histogram before matching

    Code:
    **Before matching overlaid Histograms
    twoway (histogram _pscore if $TREAT==1, blcolor("255 0 0") bfcolor(none)) (histogram _pscore if $TREAT==0, blcolor(teal) bfcolor(none))
    then finally in Step 4: I make a two way histogram after matching

    Code:
    *** histogram: viusal analysis
    //***Matching Quality***//
    sum _pscore & _weight~=.
    sum _pscore if $TREAT ==1 & _weight~=.
    sum _pscore if $TREAT ==0 & _weight~=.
    
    histogram _pscore if $TREAT==1 & _weight~=.,frequency
    histogram _pscore if $TREAT==0 & _weight~=.,frequency
    
    *psm
    twoway (histogram _pscore if $TREAT == 0, blcolor("red") bfcolor(none) legend(label(1 "M"))) (histogram _pscore if $TREAT == 1, blcolor(teal) bfcolor(none) legend(label(2 "N"))), name(PSM_grp_1)
    
    twoway (histogram _pscore if $TREAT  == 0 & _weight ~=., frequency fcolor(none) lcolor(red) lpattern(solid) legend(label(1 "M"))) (histogram _pscore if $TREAT  == 1 & _weight ~=., frequency fcolor(none) lcolor(teal) lpattern(solid) legend(label(2 "N"))), name (PSM_grp_2)
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float migrant byte language float dep_ratio byte(ind_hou shrd_hou temp_hou district jamoat) int village byte(HHH rel_spouse married unmarried widowed divorced) float(S1C_age age2)
    0 1 .11111111 1 0 0 1  1 19 0 1 1 0 0 0 46 2116
    0 1 .16666667 1 0 0 6 23 63 0 1 1 0 0 0 37 1369
    1 1 .22222222 1 0 0 1  1 19 0 1 1 0 0 0 30  900
    1 1 .16666667 0 1 0 1  1 19 0 0 1 0 0 0 46 2116
    0 1 .44444445 1 0 0 6 23 63 0 1 1 0 0 0 55 3025
    1 1 .11111111 0 1 0 1  1 19 0 1 1 0 0 0 60 3600
    1 1 .22222222 1 0 0 6 23 63 0 0 1 0 0 0 31  961
    1 1 .22222222 1 0 0 1  1 19 0 1 1 0 0 0 35 1225
    1 1 .16666667 1 0 0 6 23 63 0 1 1 0 0 0 51 2601
    1 1 .22222222 1 0 0 6 22 62 0 1 1 0 0 0 38 1444
    1 1 .16666667 0 1 0 1  1 19 1 0 0 0 1 0 59 3481
    1 1  .3333333 1 0 0 6 22 62 0 1 1 0 0 0 45 2025
    1 1  .2777778 1 0 0 1  1 19 0 1 1 0 0 0 29  841
    0 1  .2777778 0 1 0 1  1 19 0 1 1 0 0 0 66 4356
    0 1  .2777778 1 0 0 6 22 62 0 0 1 0 0 0 24  576
    1 0 .16666667 1 0 0 6 22 62 0 1 1 0 0 0 50 2500
    1 1 .16666667 1 0 0 6 22 61 0 1 1 0 0 0 29  841
    1 1 .22222222 0 1 0 1  1 19 0 0 1 0 0 0 50 2500
    1 1  .3333333 1 0 0 6 22 61 0 0 1 0 0 0 25  625
    0 1 .44444445 0 1 0 1  1 19 0 0 0 0 1 0 54 2916
    1 1 .16666667 1 0 0 6 22 61 0 1 1 0 0 0 59 3481
    1 1  .2777778 0 1 0 1  1 19 0 0 0 0 1 0 65 4225
    0 1 .05555556 1 0 0 6 22 61 0 1 1 0 0 0 56 3136
    0 1  .2777778 1 0 0 1  1 19 0 0 1 0 0 0 36 1296
    0 1 .11111111 1 0 0 6 21 60 0 1 1 0 0 0 64 4096
    0 1 .22222222 1 0 0 6 21 60 0 1 1 0 0 0 59 3481
    0 1  .3888889 1 0 0 6 22 57 0 0 1 0 0 0 64 4096
    1 1 .44444445 1 0 0 6 20 57 1 0 0 0 1 0 64 4096
    1 1 .44444445 1 0 0 6 20 57 0 0 1 0 0 0 33 1089
    1 1  .2777778 1 0 0 6 20 57 0 1 1 0 0 0 54 2916
    0 1         0 1 0 0 6 18 54 0 1 1 0 0 0 76 5776
    0 1 .11111111 1 0 0 6 18 54 0 1 1 0 0 0 44 1936
    0 1 .05555556 1 0 0 6 18 54 0 0 0 1 0 0 27  729
    1 1 .22222222 1 0 0 6 18 54 0 0 1 0 0 0 26  676
    1 1 .05555556 1 0 0 1  1 20 0 1 1 0 0 0 46 2116
    0 1 .11111111 1 0 0 6 18 54 0 1 1 0 0 0 48 2304
    0 1 .16666667 1 0 0 1  1 20 0 1 1 0 0 0 50 2500
    1 1 .11111111 1 0 0 6 18 54 1 0 0 0 1 0 63 3969
    0 1 .22222222 0 1 0 1  1 20 0 0 0 0 1 0 52 2704
    1 1 .16666667 1 0 0 6 21 60 0 0 0 0 1 0 35 1225
    1 1 .16666667 1 0 0 1  1 20 0 0 0 0 1 0 31  961
    0 1  .2777778 1 0 0 6 21 60 0 1 1 0 0 0 42 1764
    1 1  .2777778 0 1 0 1  1 20 0 0 1 0 0 0 43 1849
    1 1  .6111111 1 0 0 6 18 53 1 0 0 0 1 0 51 2601
    1 1  .3333333 1 0 0 6 18 53 0 1 1 0 0 0 47 2209
    1 1  .6666667 0 1 0 1  1 20 0 0 1 0 0 0 35 1225
    1 1 .16666667 0 1 0 1  1 20 1 0 0 0 1 0 50 2500
    0 1  .2777778 1 0 0 6 18 53 0 1 1 0 0 0 41 1681
    1 1 1.0555556 0 1 0 1  1 20 0 0 1 0 0 0 37 1369
    1 1 .11111111 1 0 0 6 18 53 0 1 1 0 0 0 37 1369
    0 1  .3333333 0 1 0 1  1 20 0 0 1 0 0 0 33 1089
    1 1 .22222222 1 0 0 6 18 53 0 1 1 0 0 0 35 1225
    0 1         0 1 0 0 1  1 20 0 0 1 0 0 0 49 2401
    0 1         0 1 0 0 6 21 60 0 1 1 0 0 0 54 2916
    0 1 .11111111 1 0 0 1  1 20 0 1 1 0 0 0 39 1521
    0 1 .44444445 1 0 0 6 18 53 0 1 1 0 0 0 34 1156
    0 1  .3333333 1 0 0 6 23 64 0 0 1 0 0 0 26  676
    1 1  .6111111 0 1 0 1  1 20 0 1 1 0 0 0 57 3249
    1 1  .3333333 1 0 0 6 23 64 0 0 1 0 0 0 31  961
    0 1 .11111111 1 0 0 6 23 64 0 1 1 0 0 0 48 2304
    0 1  .3333333 1 0 0 6 23 64 0 1 1 0 0 0 41 1681
    1 1  .3333333 1 0 0 6 23 64 0 1 1 0 0 0 67 4489
    1 1 .11111111 1 0 0 6 23 64 0 1 1 0 0 0 55 3025
    1 0 .22222222 1 0 0 6 21 59 0 1 1 0 0 0 33 1089
    1 1 .22222222 0 1 0 6 19 56 0 1 1 0 0 0 45 2025
    0 1 .22222222 1 0 0 6 19 56 0 1 1 0 0 0 31  961
    0 1  .2777778 1 0 0 6 19 55 0 1 1 0 0 0 62 3844
    1 1  .2777778 1 0 0 6 19 55 0 0 0 0 1 0 56 3136
    1 1 .11111111 1 0 0 6 19 55 0 0 1 0 0 0 22  484
    1 1         0 0 1 0 1  6 21 0 1 1 0 0 0 50 2500
    1 1 .11111111 1 0 0 6 19 55 0 0 1 0 0 0 23  529
    1 1 .11111111 1 0 0 1  6 21 0 1 1 0 0 0 50 2500
    1 1 .16666667 1 0 0 6 19 55 0 1 1 0 0 0 47 2209
    1 1  .2777778 1 0 0 1  6 21 0 0 1 0 0 0 67 4489
    0 1 .16666667 1 0 0 6 19 55 0 1 1 0 0 0 41 1681
    1 1 .16666667 1 0 0 6 21 59 0 1 1 0 0 0 37 1369
    1 1  .3888889 0 1 0 1  6 21 0 1 1 0 0 0 61 3721
    1 1 .16666667 1 0 0 6 21 59 0 1 1 0 0 0 25  625
    1 1  .8333333 0 1 0 1  6 21 0 0 0 0 1 0 32 1024
    1 1  .3333333 1 0 0 6 21 59 1 0 0 0 1 0 53 2809
    0 1 .16666667 1 0 0 1  6 21 0 0 0 0 1 0 63 3969
    1 1 .11111111 1 0 0 6 19 56 0 1 1 0 0 0 28  784
    0 1 .22222222 1 0 0 6 23 63 0 1 1 0 0 0 38 1444
    0 1 .16666667 1 0 0 1  6 21 0 1 1 0 0 0 36 1296
    0 1 .22222222 0 1 0 1  6 21 0 0 1 0 0 0 26  676
    1 1 .22222222 1 0 0 1  6 21 0 0 1 0 0 0 26  676
    1 1  .2777778 1 0 0 1  6 21 0 1 1 0 0 0 40 1600
    1 1 .05555556 1 0 0 1  6 21 0 1 1 0 0 0 44 1936
    1 1 .11111111 1 0 0 1  6 21 0 1 1 0 0 0 39 1521
    1 1 .11111111 0 1 0 1  6 22 0 1 1 0 0 0 48 2304
    1 1 .11111111 0 1 0 1  6 22 0 1 1 0 0 0 42 1764
    0 1 .16666667 1 0 0 1  6 22 1 0 1 0 0 0 56 3136
    0 1 .05555556 1 0 0 1  6 22 0 1 1 0 0 0 54 2916
    0 1 .11111111 1 0 0 1  6 22 0 1 1 0 0 0 45 2025
    0 1 .11111111 1 0 0 1  6 22 0 1 1 0 0 0 41 1681
    0 1 .11111111 0 1 0 1  6 22 0 1 1 0 0 0 55 3025
    1 1  .3888889 0 1 0 1  6 22 0 1 1 0 0 0 50 2500
    0 1 .16666667 0 1 0 1  6 22 1 0 0 0 1 0 57 3249
    0 1 .22222222 1 0 0 1  6 22 0 1 1 0 0 0 33 1089
    0 1 .11111111 0 1 0 1  6 22 0 0 1 0 0 0 25  625
    end

  • #2
    Hi Naika,

    A few notes:
    1) you should use propensity score estimated from probit model in the second step
    2) After obtaining the propensity score, you should sort your data at random to avoid bad matches
    3) you should specify your outcome variable in psmatch2 command
    4) you also may want to use -common- option to increase the matching quality
    5) you also may want to try different matching methods

    Taken together, you may try something like - here I use kernel matching but you can explore others
    Code:
    probit $TREAT $HH $GEO $HH_RESP
    predict ps
    
    set seed 100
    generate u=runiform()
    sort u
    psmatch2 $TREAT $HH $GEO $HH_RESP, kernel outcome(your outcome) common bw(0.06) ps(ps)
    You also can do matching in only one step
    Code:
    psmatch2 $TREAT $HH $GEO $HH_RESP, kernel outcome(your outcome) common bw(0.06)
    Hope this helps

    Comment


    • #3
      Thank you so much Dung! This clarified my confusion.

      Comment


      • #4
        Hi Dung,

        I used the following codes after your advice. When i build my histogram i get the below graph. could it be correct? when i look at samples from others it looks rather different.


        Code:
        *nearest neighbor matching
        psmatch2 $TREAT, outcome($FS $WATACC $GEN) pscore(ps) neighbor(5) common bw(0.06)
        *Kernel Matching
        psmatch2 $TREAT, kernel outcome($FS $WATACC $GEN) pscore(ps) common bw(0.06)
        *Radius Matching
        psmatch2 $TREAT, radius outcome($FS $WATACC $GEN) pscore(ps) common bw(0.06)
        Attached Files

        Comment


        • #5
          Hi Naika,

          I do not how do you define your treatment and outcomes (e.g., what do $TREAT, $FS, $WATACC, and $GEN mean because you did not provide detailed information on those variables in #1) so I can not provide further advice. Also, I don't know what Stata command did you use to produce the graph so I can't comment either. However, you may want to take the following comments into consideration.
          1) I do not know the purpose of your graph and I also don't what "others' graph look like so I can not say anything about that. But, if you want to produce a graph showing common support between the treatment and control group. You can try the following
          Code:
          probit enrolled $covariate
          predict ps
          kdensity ps if treat ==1, gen(treat1 den1)
          kdensity ps if treat ==0, gen(treat0 den0)
          twoway (line den0 treat0) (line den1 treat1)
          2) after matching you may want to use user-written commands: -psgraph- and -pstest-, written by Leuven and Sianesi to examine the matching quality.
          3) in the future, if you want to attach a picture, please use .png extension so that your picture can be visible.

          Comment


          • #6
            Hi Dung,

            Thank you so much for your advice and I apologize for being unclear about my question. I was instructed to make the graph as it is an easy way to show how successful our matching is. I used the following command to make my histogram This was for the Nearest Neighbor matching. Would you recommend that i just use psgraph and not the below histogram? Thank you once again.

            Code:
            *** histogram: viusal analysis
            twoway (histogram _pscore if $TREAT == 0, blcolor("red") bfcolor(none) legend(label(1 "M"))) (histogram _pscore if $TREAT == 1, blcolor(teal) bfcolor(none) legend(label(2 "N"))), name(PSM_grp_188)
            
            twoway (histogram _pscore if $TREAT  == 0 & _weight ~=., frequency fcolor(none) lcolor(red) lpattern(solid) legend(label(1 "M"))) (histogram _pscore if $TREAT  == 1 & _weight ~=., frequency fcolor(none) lcolor(teal) lpattern(solid) legend(label(2 "N"))), name (PSM_grp_288)

            Click image for larger version

Name:	example.JPG
Views:	1
Size:	85.3 KB
ID:	1580173





            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input float(S8_migrant S7_fsm_mnths S7_mea_pr_food S7_4_weeks S4C_need_recei) byte(S4C_paywat S4C_adv_info)
            0 2 5 1 -1 1 1
            0 2 5 1 -5 1 0
            1 0 0 0  0 1 1
            1 2 4 1 -2 1 0
            0 2 5 1  0 1 0
            1 0 0 0  0 1 0
            1 5 3 1  1 1 1
            1 0 0 0  0 1 1
            1 0 4 0 -3 1 0
            1 2 5 3  2 1 0
            1 3 3 3 -3 1 0
            1 1 3 1  0 1 0
            1 0 0 0  0 1 1
            0 2 2 0  0 1 1
            0 2 3 1  0 1 0
            1 2 4 1  1 1 0
            1 2 6 1 -3 1 0
            1 0 2 0 -1 1 1
            1 0 4 0  7 1 0
            0 6 6 1  1 1 1
            1 1 2 0  1 1 0
            1 2 2 1 -2 1 0
            0 0 0 0 -3 1 0
            0 0 0 0 -2 1 1
            0 2 5 3 -2 1 0
            0 1 5 1 -5 1 1
            0 2 4 0  2 1 0
            1 1 0 0  3 1 0
            1 0 3 1  2 1 0
            1 1 4 1 -1 1 0
            0 1 5 1 -2 1 0
            0 2 4 1  4 1 0
            0 1 3 2  0 1 0
            1 2 2 0 -3 1 0
            1 0 4 0 -3 1 0
            0 2 4 0  1 1 0
            0 2 3 0  0 1 0
            1 0 2 0 -1 1 0
            0 2 4 0 -2 1 0
            1 1 5 1 -2 1 0
            1 2 4 0  0 1 0
            0 0 3 0  0 1 0
            1 0 1 0 -2 1 0
            1 2 4 2 -3 1 0
            1 1 3 1  0 1 0
            1 1 2 0  0 . .
            1 2 1 0 -5 1 0
            0 0 3 0 -5 1 0
            1 2 1 1  2 1 0
            1 0 0 0  0 1 0
            0 2 5 2 -4 1 0
            1 0 0 0  7 1 0
            0 2 2 1 -2 1 0
            0 1 7 3 -4 1 1
            0 4 3 0 -1 1 0
            0 0 4 0 -1 1 0
            0 0 0 0 -5 1 0
            1 0 0 0  0 1 0
            1 1 4 3 -3 1 1
            0 2 4 0 -2 1 0
            0 2 3 2 -1 1 0
            1 2 7 3 -4 1 0
            1 3 6 2 -6 1 1
            1 2 3 3  1 1 0
            1 2 6 3  0 1 1
            0 1 5 2 -4 1 0
            0 2 6 3 -1 1 0
            1 1 4 2  1 1 0
            1 1 6 3  4 1 0
            1 5 4 1 -3 1 0
            1 2 6 3 -1 1 0
            1 1 4 2  0 1 0
            1 2 3 2  7 1 0
            1 0 0 0 -1 1 0
            0 0 0 0 -4 1 0
            1 1 5 2  1 1 0
            1 0 1 0  0 1 0
            1 1 4 0 -6 1 0
            1 5 4 3 -4 1 0
            1 0 0 0  0 1 0
            0 2 5 1  0 1 0
            1 3 6 1 -5 1 0
            0 2 4 1 -1 1 0
            0 4 6 2 -2 1 1
            0 3 5 2 -3 1 0
            1 0 0 0  0 1 0
            1 3 2 1 -3 1 0
            1 2 0 0  0 1 1
            1 2 0 0  0 1 0
            1 0 1 0 -4 0 1
            1 2 2 1 -8 1 0
            0 0 2 1 -4 1 0
            0 3 5 2  0 1 0
            0 0 0 0  0 0 0
            0 0 0 0 -2 1 0
            0 1 0 0 -7 1 0
            1 2 1 0  1 1 0
            0 3 2 0 -2 1 1
            0 0 1 0 -1 1 0
            0 0 0 0 -8 1 0
            end

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input byte(S3_brk_soil_K S3_lssn_soil_K S3_prchse_agri_K S3_sow_sed_K S3_weed_K S3_pruns_K S3_set_irri_K S3_guide_wat_K S3_clean_irri_K S3_clean_sml_irri_K S3_wht_har_K S3_har_crop_K S3_plough_K)
            1 1 1 0 0 1 1 1 1 1 . . 1
            . 1 1 0 0 1 0 0 . . 0 0 0
            1 1 1 1 0 1 1 1 1 1 . . 1
            1 0 1 0 0 1 0 1 1 1 . . 0
            . 1 1 1 0 1 1 1 1 1 . 1 1
            1 1 1 1 0 1 1 1 1 1 . . 1
            1 1 1 1 1 1 1 1 1 1 . 1 1
            1 1 1 1 0 1 1 1 1 1 . . 1
            . 1 1 1 0 1 1 1 1 1 . 0 .
            0 0 1 0 0 1 0 0 1 1 . . 0
            . . 0 0 0 . 0 0 0 0 . . 0
            1 1 1 0 0 1 1 1 . 0 . 0 0
            1 1 0 0 0 0 0 0 0 0 . . .
            1 1 1 1 0 1 1 1 1 1 . . 1
            1 1 0 0 0 1 1 1 1 1 . 0 0
            1 1 1 0 0 1 1 1 1 1 . 0 1
            1 1 0 0 0 1 1 1 1 1 . 0 1
            . . 1 1 0 1 1 1 1 1 . . .
            1 1 1 0 0 1 1 1 1 1 . 1 1
            . . 1 1 0 1 1 1 1 1 . . .
            1 1 1 1 0 1 1 1 1 1 . 1 1
            . . 1 0 0 1 0 1 1 0 . . .
            0 0 1 0 0 1 1 0 1 0 . 0 0
            . . 1 1 0 . 1 1 1 1 . . .
            1 1 1 0 0 1 1 1 1 1 . 0 1
            0 0 0 0 0 1 0 0 1 0 . 0 0
            1 1 1 0 0 1 1 1 1 1 . 0 1
            0 1 0 0 0 1 1 0 1 0 . 0 1
            0 1 1 1 0 1 1 1 1 1 . 0 1
            1 1 0 1 0 1 1 1 1 1 0 0 1
            . . 0 . . 0 0 0 . . . 0 .
            1 1 1 1 0 1 1 1 1 1 . 0 1
            1 0 1 0 0 1 0 0 1 1 . 0 .
            1 1 1 1 0 1 1 1 1 1 . 0 .
            1 1 . 0 0 . 1 1 1 1 . . .
            1 0 1 0 0 1 1 1 1 0 . 0 1
            0 0 0 0 0 0 0 0 0 1 . . 0
            1 1 1 1 0 1 1 1 1 1 . 0 .
            1 1 1 0 0 1 1 0 1 1 . . .
            1 1 1 1 0 1 1 1 1 1 . 1 1
            1 1 1 1 0 1 1 1 1 1 . . 1
            1 1 1 1 0 1 1 1 1 1 . 0 1
            0 0 0 0 0 1 . 0 0 0 . 0 .
            0 0 0 0 0 . 0 0 1 0 . 0 1
            1 1 1 0 0 1 1 1 1 1 . 0 1
            . . . . . . . . . . . . .
            0 0 0 0 0 . 0 0 0 1 . . 0
            1 1 1 1 0 1 1 1 1 1 . 0 1
            1 1 1 1 0 1 1 1 1 1 . . 1
            . 1 1 1 0 1 1 1 1 1 1 1 .
            0 0 0 1 0 1 1 1 1 0 . . .
            1 1 1 1 0 . . . . . . 0 .
            0 0 1 0 0 1 1 0 . 0 . . .
            1 1 1 1 0 1 1 1 1 1 . 0 1
            0 0 0 0 0 1 0 0 0 0 . . .
            0 0 1 0 0 1 1 0 1 0 . 0 .
            . 1 1 0 0 1 1 1 1 1 . 0 .
            1 0 1 1 0 0 0 0 1 1 . . 0
            . 0 1 0 0 1 0 0 1 0 . 0 .
            1 1 1 0 0 1 1 1 1 0 . 0 .
            0 0 1 0 0 . 1 1 1 0 . 0 1
            0 0 0 0 0 0 0 0 0 0 . 0 0
            1 1 1 1 0 1 1 1 1 1 . 0 1
            . 1 0 1 0 1 1 0 1 0 0 0 .
            . 0 1 0 0 . 1 1 1 1 . 0 .
            1 1 1 0 0 1 1 1 1 0 0 0 .
            . 0 1 1 0 1 1 1 1 1 1 . .
            . 1 0 1 0 1 1 1 1 1 . 0 .
            1 1 1 1 0 1 1 1 1 1 . 0 1
            0 1 1 0 0 1 0 0 1 0 . . 1
            1 1 1 1 0 1 1 1 1 1 . 1 1
            1 1 1 0 0 1 1 1 1 1 . . 1
            0 1 0 0 0 1 1 1 1 1 . . 1
            . 1 1 1 0 1 1 1 . . . . .
            1 1 1 1 0 1 1 1 1 1 . 0 .
            1 1 1 0 0 1 1 1 1 1 . 0 1
            1 1 1 1 0 1 1 1 . 1 . . .
            . 0 0 0 0 . 0 0 1 0 . 0 .
            0 0 1 0 0 0 0 0 0 0 . . 0
            1 1 0 0 0 1 1 1 1 1 . 0 .
            1 1 1 1 0 1 1 1 1 1 . . 1
            0 0 0 0 0 1 1 0 1 0 . 0 0
            1 1 1 0 0 1 1 1 1 1 . 1 .
            . 0 1 0 . 1 0 1 1 1 . . 0
            . . 1 0 0 1 1 0 1 1 . 0 .
            0 0 1 0 0 1 1 1 1 0 . . 0
            0 0 1 0 0 0 1 1 1 1 . . .
            0 0 0 0 0 1 0 0 0 1 . . .
            1 1 1 0 0 1 1 1 1 1 . . 1
            1 1 1 0 0 1 1 1 . . . . 1
            1 1 1 0 0 1 1 0 . . . . 1
            0 0 0 0 0 0 0 0 . . . . .
            1 0 1 0 0 1 . . . . . . 1
            1 0 1 0 0 1 . 1 . 0 . . 1
            1 1 1 1 1 1 1 1 . . . . 1
            1 1 0 1 0 1 . 1 . . . . 1
            1 1 1 0 0 1 1 1 . . . . 1
            1 1 1 1 0 . 1 1 . . . . 1
            0 . 1 0 0 0 0 0 . . . . .
            1 1 0 1 0 1 . 1 . . . . 1
            end

            Comment


            • #7
              Hi Naika,

              I think it's just a matter of taste. I myself find -psgraph- quite illustrative. if I have two methods addressing the same issue then I would choose one that is less complicated and easier to interpret results (assuming that the two methods give the same results). I normally use -psgraph- command. Please note that graphing is an illustrative way to present data but if you want to examine the matching quality you then may want to do some tests and -pstest- was born to do so. type help pstest (if installed) for more detail.

              Comment


              • #8
                Hi Dung,

                Thank you again for all the advice. I will use psgraph and pstest as you suggest.

                Comment


                • #9
                  Hi Dung,

                  I am not sure why but when i use the following code
                  Code:
                  psmatch2 $TREAT,  neighbor(5) outcome($FS $WATACCESS $GENDER_LABR) pscore(ps) common bw(0.06)
                  My observations goes down from 1920 to just 38. How can i fix this? Because i cannot do any analysis with such less observations.

                  Comment


                  • #10
                    Hi Naika,

                    If the number of observation in your treatment group is relatively small compared to that of your control group, then you may want to consider using kernel or radius matching instead of neighbor matching.

                    Comment


                    • #11
                      Hi Dung,

                      It was because one of my variables only had 138 observations so I decided to not include it in my study.

                      I want to graph the results from pstest matched and unmatched. Is it possible to do so? How can i graphically show the confounding variables before and after matching? Thank you so much for all your help so far.

                      Comment


                      • #12
                        Hi Dung and others who might be looking at this post i used the following code that i found in a different post on statalist (https://www.statalist.org/forums/for...score-matching)
                        Code:
                        // 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
                        posted by Richard Hofler. Thanks everyone for the help.

                        Comment


                        • #13
                          Originally posted by Dung Le View Post
                          Hi Naika,

                          A few notes:
                          1) you should use propensity score estimated from probit model in the second step
                          2) After obtaining the propensity score, you should sort your data at random to avoid bad matches
                          3) you should specify your outcome variable in psmatch2 command
                          4) you also may want to use -common- option to increase the matching quality
                          5) you also may want to try different matching methods

                          Taken together, you may try something like - here I use kernel matching but you can explore others
                          Code:
                          probit $TREAT $HH $GEO $HH_RESP
                          predict ps
                          
                          set seed 100
                          generate u=runiform()
                          sort u
                          psmatch2 $TREAT $HH $GEO $HH_RESP, kernel outcome(your outcome) common bw(0.06) ps(ps)
                          You also can do matching in only one step
                          Code:
                          psmatch2 $TREAT $HH $GEO $HH_RESP, kernel outcome(your outcome) common bw(0.06)
                          Hope this helps
                          Hello there I've tried using this code to help me with matching but I keep getting this error for this code:

                          psmatch2 $treatment $xlist, outcome($ylist) common bw(0.06) ps(ps)
                          You cannot specify both a varlist AND a propensity score
                          r(198);

                          end of do-file


                          Data used:

                          webuse cattaneo2

                          Research question:
                          Does alochol effect birth weight in ?

                          Matching on: maternal age, maternal education, maternal smoking.

                          Macros generated:


                          *Creating macros
                          global treatment alcohol //intervention/treatment
                          global ylist bweight //outcome
                          global xlist mage medu msmoke //variables to match on

                          ***MATCHING ****

                          SECTION A:

                          probit $treatment $mage $medu $msmoke
                          predict ps

                          set seed 100 //sorts this out randomly
                          generate u=runiform()
                          sort u

                          **This doesn't work says 'cannot specify both varlist and a propensity score '
                          psmatch2 $treatment $xlist, outcome($ylist) common bw(0.06) ps(ps)

                          SECTION B:

                          However I tried this code instead - but this uses Logit not Probit. I understand Probit is recommended.

                          psmatch2 alcohol mage medu msmoke, outcome(bweight) n(3) logit

                          Therefore my question:

                          1. Why am I getting an error for Section A code
                          2. Why is Probit recommended for use vs logit?

                          Comment

                          Working...
                          X