Announcement

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

  • Add one more legend for yline

    I am currently using sdid and want to add the mean of outcome variable to the graph output, and I choose the treated group mean since the control group are synthetic. Here is the code I use for the graph:
    Code:
    eststo sdid_1: sdid r_wo state date treat, vce(placebo) covariates(pop_1000 r_black r_notwhite unemploymentrate income_per_capita r_HS r_college lgdp tdate tstate, optimized) seed(1234) graph g1on ///
    g2_opt(yline(0.08, lp(dash) lc(black)) ytitle("Crime involving drug only without possession") ylabel(0.08 "0.08") note("Black dash line means the mean of treated group"))
    
    *obtain the mean of the treated group since control group are synthetic
    matrix ytr = e(series)[1..25,3]
    svmat ytr
    
    sum ytr1
    local treated_mean: di %3.2f r(mean)
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
            ytr1 |         25    .0803029    .0073493   .0670233   .0947042
    Actually the number 0.08 is I obtain from following, and I ran the code again with the number
    Code:
    *obtain the mean of the treated group since control group are synthetic
    matrix ytr = e(series)[1..25,3]
    svmat ytr
    
    sum ytr1
    local treated_mean: di %3.2f r(mean)
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
            ytr1 |         25    .0803029    .0073493   .0670233   .0947042
    Click image for larger version

Name:	Screenshot 2024-04-30 155639.png
Views:	1
Size:	152.8 KB
ID:	1751729


    And generate graph above, but this is not what I want. I want to have the legend information about the yline, also I don't want the y label to disappear, just want to emphasis the number of the mean which is 0.08 in this case. Sorry I use the paint tool to edit the graph to show what I really want.
    Click image for larger version

Name:	Screenshot 2024-04-30 155939.png
Views:	1
Size:	146.3 KB
ID:	1751730

    Last edited by Wenhan Yan; 30 Apr 2024, 02:18.
Working...
X