Announcement

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

  • How to graph heterogeneity of treatment effects for standardised indices

    Hello,

    I have data on a social norms experiment and wish to have a graph that displays the heterogeneity of treatment effects according to the richness of respondents’ social environments (“rich” vs “poor”).

    To create the coefficient plots shown, I have written the code given below. However, I would like to standardise the indices and unfortunately after various tests I am at a loss as to how to adapt my code for standardised indices.

    To explain the variables used:
    • Respondents indicated on a 5-point Likert scale the degree to which they agreed with 2 separate statements indicating “richness” of social environment
      • Strongly agree = coded ‘9’ = “very rich”
      • Strong disagree = coded ‘13’ = “very poor”
      • The values in the remaining range fill the gap.
    • Respondents completed the above for each type of extracurricular activity they participate in e.g., course-based, non-profit, sports etc.
    • I created an index for overall social environment richness within each activity.
    • From this, I created an index aggregating over all activities to indicate a general measure of social environment richness.
    To explain my code:
    • I did a loop to regress run a regression of my main outcome variable (‘Donations’) on each variable, a treatment indicator, and a set of background characteristics.
    • To separately analyse treatment effects for ‘rich’ vs ‘poor’ social environments, responses which averaged to strongly agree or agree (if `var'<10.5) with the given statements are taken to indicate a socially rich environment. Responses averaging as neutral or less are considered as a ‘poor’ social environment (if `var'>=10.5).
    • I used the user-written command coefplot
    My question
    • How can heterogeneity of treatment effects be shown for these standardised indices?
    Below is given (i) desired type of graph (ii) my current graphs (using unstandardised indices) (iii) code (iv) dataex (unstandardised & standardised data given).

    If you wish for any further information, please let me know and I will provide it.

    (i) Desired type of graph

    Click image for larger version

Name:	Statalist1.png
Views:	1
Size:	75.1 KB
ID:	1661380


    (ii) My figure: Treatment effect heterogeneity by richness of social environment (only my Behaviour treatment is given below)

    Click image for larger version

Name:	Statalist2.png
Views:	1
Size:	89.7 KB
ID:	1661381


    (iii) Code (w/simplified control variables)
    Code:
    set scheme s1color
      
    foreach var in SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall {
           quietly regress Donation `var' dGroupid2 Gender if `var'<10.5
           estimates store `var'
       }
     
    coefplot (SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall, label(Behaviour)), drop(dGroupid2 Gender _cons) mlabel(cond(@pval<.001, "<0.001" + "***", ///
    cond(@pval<.01, string(@pval,"%9.3f") + "**", ///
    cond(@pval<.05, string(@pval,"%9.3f") + "*", ///
    string(@pval,"%9.3f"))))) ///
    note("p-values shown alongside markers" "* p<0.05, ** p<0.01, *** p<0.001") xline(0) title("{bf: Panel A.1:} Rich social environment") name(Figure3BehRichZ, replace)
    eststo clear
     
    foreach var in SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall {
           quietly regress Donation `var' dGroupid2 Gender if `var'>=10.5
           estimates store `var'
       }
     
    coefplot (SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall, label(Behaviour)), drop(dGroupid2 Gender _cons) mlabel(cond(@pval<.001, "<0.001" + "***", ///
    cond(@pval<.01, string(@pval,"%9.3f") + "**", ///
    cond(@pval<.05, string(@pval,"%9.3f") + "*", ///
    string(@pval,"%9.3f"))))) ///
    note("p-values shown alongside markers" "* p<0.05, ** p<0.01, *** p<0.001") xline(0) title("{bf: Panel A.2:} Poor social environment") name(Figure3BehPoorZ, replace)
    eststo clear
     
    graph combine Figure3BehRichZ Figure3BehPoorZ
    Code:
    dataex dGroupid2 Donation Gender SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall SEIndex_sports_Zz SEIndex_political_Zz SEIndex_nonprof_Zz SEIndex_course_Zz SEIndex_relg_Zz SEIndex_overall_Zz
    
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte dGroupid2 int Donation byte Gender float(SEIndex_sports SEIndex_nonprof SEIndex_course SEIndex_relg SEIndex_overall SEIndex_sports_Zz SEIndex_political_Zz SEIndex_nonprof_Zz SEIndex_course_Zz SEIndex_relg_Zz SEIndex_overall_Zz)
    0  50 5   10    .    .    .    10 -.02870074           .           .          .          .  -.02870074
    0  15 5    9    .    .  9.5  9.25  -.9106002           .           .          .  -.6535326   -.7820664
    0  40 5    9   11    .    .    10  -.9106002           .   1.1277212          .          .    .1085605
    0  90 6    9    .    .    .     9  -.9106002           .           .          .          .   -.9106002
    0  80 6    9    .    .    .     9  -.9106002           .           .          .          .   -.9106002
    0 110 5    .    .    .   10    10          .           .           .          . -.04202402  -.04202402
    0 110 5 10.5    .    .   10 10.25    .700974           .           .          . -.04202402     .329475
    0  64 6    .   10    .   10    10          .           . -.030996576          .  -.0872079  -.05910224
    0  84 6    .    .   11 10.5 10.75          .           .           .  1.3673325   .4791168    .9232246
    0  55 6  9.5    .  9.5    .   9.5  -.4696505           .           .  -.4725748          .   -.4711126
    0  84 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    0  90 5  9.5    .  9.5  9.5   9.5  -.4696505           .           .  -.4725748  -.6083487    -.516858
    0 110 5    .    .    .    .    10          . -.070030846           .          .          . -.070030846
    0  39 6    .    .   10   10    10          .           .           .  .14072762  -.0872079  .026759863
    0 110 6    .    .    .    .     .          .           .           .          .          .           .
    0  50 6    9    .   10    .   9.5  -.9106002           .           .  .14072762          .   -.3849363
    0  50 5    .    .    .    .     .          .           .           .          .          .           .
    0  45 6   10    .   10 10.5  10.1 -.02870074           .           .  .14072762   .4791168    .1970479
    0 100 6    .    .    .    .     .          .           .           .          .          .           .
    0 110 6   10    .    .   10    10  .26002425           .           .          .  -.0872079   .08640818
    0  10 6    9    9 10.5   11 10.08  -.9106002 -.070030846  -1.1897144    .687457  1.0002576   .11378258
    0  55 5    9    .    9    .     9  -.9106002           .           . -1.0193042          .   -.9649522
    0 110 6   11    .   11    .  10.6  1.1419237           .           .  1.3673325          .    .8560902
    0  90 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    0  30 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    0  59 5   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    0  55 5    .   10    .    .    10          .           . -.030996576          .          . -.030996576
    0  20 6    .    .    .    .     .          .           .           .          .          .           .
    0  80 5 11.5    .    .    .  11.5  1.5828733           .           .          .          .   1.5828733
    0  30 5 10.5    .    .    .  9.75    .412249           .           .          .          .  -.31752425
    0  55 5    9    . 10.5  9.5   9.6  -.9106002           .           .    .687457  -.6535326  -.29222527
    0  28 5   10    .   10   10    10  .26002425           .           .  .14072762  -.0872079    .0931396
    0  20 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    0   0 5   10    .    9    .   9.5  .26002425           .           . -1.0193042          .  -.37963995
    0  20 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    0 110 5    .    .    9 10.5 10.17          .           .           . -1.0193042   .4791168   .16081707
    0  71 5    .   10    .    .    10          .           . -.030996576          .          . -.030996576
    0  20 5    9    .    .    .     9  -.9106002           .           .          .          .   -.9106002
    0 110 5  9.5    .  9.5    .   9.5  -.4696505           .           .  -.4725748          .   -.4711126
    0 110 6    .   10    .    .    10          .           . -.030996576          .          . -.030996576
    0  14 5   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    0  75 5   11    .   10    .  10.5  1.7193736           .           .  .14072762          .    .9300506
    0  50 6    . 10.5    . 10.5  10.5          .           .    .4989063          .   .3887489    .4438276
    0 110 6    . 10.5   10 10.5  10.3          .           .    .4989063  .14072762   .4339329    .3578556
    0  60 5   11    .    .    .    11   .8531986           .           .          .          .    .8531986
    0  70 5   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    0  95 6    9    .    .    .     9  -.9106002           .           .          .          .   -.9106002
    0 110 6 11.5    9   11    . 10.13  1.5828733  -1.4779074  -1.1897144  1.1676135          .   .02071625
    0  10 5 11.5    . 10.5    .    10  2.1603234           .           .    .687457          .   1.4238902
    0 100 6   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    0  52 6    .    .    .    .     .          .           .           .          .          .           .
    0  15 5   10    9    9    .   9.9  .26002425    .4570154  -1.1897144 -1.0193042          .  -.06533051
    0  55 5    9    .    .    .     9  -.9106002           .           .          .          .   -.9106002
    0  82 5    .    .    .    .  10.5          .           .           .          .          .    .5408265
    0  95 6    .    .    .    .     .          .           .           .          .          .           .
    0  70 6    9    .   11    .    10  -.9106002           .           .  1.3007594          .   .19507962
    0  10 5    .    .  9.5    .   9.5          .           .           .  -.4060018          .   -.4060018
    0 110 6 10.5 10.5  9.5 10.5 10.25    .700974           .    .4989063  -.4725748   .4791168    .3016056
    0  11 6    9    9    9    9     9  -.9106002           .  -1.1897144 -1.0193042 -1.1746734  -1.0683179
    0  20 5 10.5    .    .    .  10.5    .700974           .           .          .          .     .700974
    0   1 5   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    0 110 5    . 10.5 10.5    .  10.3          .   -.4238149    .4989063    .687457          .   .25418282
    0   1 5  9.5    .    .    .   9.5 -.18092546           .           .          .          .  -.18092546
    0  90 6    .    .    .   11    11          .           .           .          .  1.0454415   1.0454415
    0 110 6   11  9.5    .    .    10  1.1419237           .   -.6598114          .          . -.027791044
    0 110 5    .    .    .    .     .          .           .           .          .          .           .
    1  55 6  9.5    .    9    .  9.25  -.4696505           .           . -1.0193042          .   -.7444773
    1 110 6  9.5    .  9.5    .   9.5  -.4696505           .           .  -.4725748          .   -.4711126
    1 110 6    .    .    .  9.5   9.5          .           .           .          .  -.6083487   -.6083487
    1   0 5 11.5    .    .    .  11.5  1.5828733           .           .          .          .   1.5828733
    1  63 6    .   11    .    .    11          .           .   1.1277212          .          .   1.1277212
    1 105 6  9.5   10    9    .   9.6 -.18092546           . -.030996576 -1.0193042          .   -.4104087
    1   0 5    .    .    .    .     .          .           .           .          .          .           .
    1 110 6    9    .    .    .     9  -.9106002           .           .          .          .   -.9789488
    1 110 6   10    .   10   10    10  .26002425           .           .  .14072762  -.0872079   .10451466
    1 110 5    .    .    9    .     9          .           .           . -1.0193042          .  -1.0193042
    1 110 6   10    .  9.5    9   9.5  .26002425           .           .  -.4060018 -1.1746734    -.440217
    1 110 5    .    .    .    .     .          .           .           .          .          .           .
    1  90 5    .    . 10.5    .    11          .    1.864892           .    .687457          .   1.2761745
    1  55 6  9.5    .    .    9  9.25  -.4696505           .           .          . -1.1746734    -.822162
    1  80 6    .   10    9   10  9.67          .           . -.030996576 -1.0193042  -.0872079  -.37916955
    1  50 6    .    .    .    .     .          .           .           .          .          .           .
    1  50 6    .    .    .    .  10.5          .    .4570154           .          .          .    .4570154
    1   0 5    .    .    .   10    10          .           .           .          .  -.0872079   -.0872079
    1  90 6    9    .   10    .   9.5  -.9106002           .           . .074154645          .   -.4182228
    1   0 5   10    .   11  9.5 10.17 -.02870074           .           .  1.3007594  -.6083487  -.09589688
    1 110 5   11 10.5    .    . 10.75  1.1419237           .    .5978183          .          .     .869871
    1  55 6    .    .    . 10.5  10.5          .           .           .          .   .4791168    .4791168
    1  63 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    1  33 6 10.5    .    . 10.5  10.5    .412249           .           .          .   .5243007    .4682748
    1  33 6 10.5    .    . 10.5  10.5    .412249           .           .          .   .5243007    .4682748
    1  40 5 10.5    .    . 11.5    11    .700974           .           .          .  1.5213984   1.1111863
    1  84 5  9.5    .    .    .   9.5  -.4696505           .           .          .          .   -.4696505
    1  20 6   11    .    .    .    11  1.1419237           .           .          .          .   1.1419237
    1 110 6  9.5  9.5    .    .   9.5  -.4696505           .   -.5608995          .          .    -.515275
    1  90 6   10    .    .    .    10  .26002425           .           .          .          .   .26002425
    1  29 6    .  9.5    .   10  9.83          . -.070030846   -.6598114          . -.04202402  -.25728875
    1  80 6    .   10   11 11.5 10.83          .           . -.030996576  1.3007594  1.5213984    .9303871
    1 110 5   11    .   10   10  10.3  1.4306487           .           .  .14072762  -.0872079    .4947228
    1  50 6    .    .    .   11    11          .           .           .          .   .9550737    .9550737
    end
    label values Gender Gender_lbl
    label def Gender_lbl 5 "male", modify
    label def Gender_lbl 6 "female", modify
    label values SEIndex_overall SEIndex_overall
Working...
X