Announcement

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

  • yline() and shadow for IC

    Hello!

    Im posting this because i need help with 2 things:

    1. I need to add a red yline() That takes the value of 0 from, -12 to 0 (x axsis). And then From 1 to 12, takes another value, for example lets say -0.04
    2. Wondering if i can add shadow for the IC. Instead of the classic IC (as is now in the graph).

    Im using STATA /SE 18.0

    Here de DATA: https://drive.google.com/file/d/1oGz...ew?usp=sharing

    And here is the code:

    Thanks!

    #delimit ;

    graph twoway (rcap max95 min95 EventYear, mcolor(black) lcolor(black) lpattern(solid))
    (scatter estimate EventYear, mcolor(black) lcolor(black) lpattern(solid) m(d) ),
    graphregion(fcolor(white) lcolor(white) lwidth(vvvthin) ifcolor(white) ilcolor(white) ilwidth(vvvthin))
    title( "{stSerif:{bf:Figure 1. {it:Event Study: cotiza_pension}}}", color(black) size(large))
    xtitle("{stSerif:Meses Desde el Derecto de Ley Migración}") xscale(titlegap(2))
    xline(0, lcolor(black) lpattern(dash)) legend(off)
    yline(0, lcolor(black) lpattern(dash))
    yline(-0.1 -0.05 0 0.05 0.1, lwidth(vvvthin) lpattern(dash) lcolor(black))
    xlabel(#17,valuelabel nogrid)
    note("{stSerif:{it:Notes}. OLS coefficient estimates (and their 95% confidence intervals) are reported.}"
    "{stSerif: Especificación 2.}", margin(small)) ;

    #delimit cr
    Click image for larger version

Name:	Screen Shot 2023-11-16 at 12.26.40 PM.png
Views:	1
Size:	72.0 KB
ID:	1734092


  • #2
    I don't know what IC means here, or indeed anywhere, as I imagine it doesn't mean infiltration capacity.

    Added lines always extend from one side to another in the plot region.

    If you want something else, use twoway function (for horizontal lines) or twoway scatteri with option recast(line) (generally). There are other ways to do it, but those are top of my list.
    Last edited by Nick Cox; 16 Nov 2023, 09:51.

    Comment


    • #3
      Present a data example using the dataex command, as recommended in FAQ Advice #12. Some questions to address if you reconsider reposting:

      1. What is IC? Do you mean CI for confidence interval?
      2. I do not follow what you mean by "shadow" (maybe others do). Perhaps an area plot?

      Comment


      • #4
        Yes sorry, IC is CI in Spanish. Confidence Interval. Andrew Musau Nick Cox

        Comment


        • #5
          And Shadow. Like shaded area confidence intervals (imagine similar to area plot) Andrew Musau

          Comment


          • #6
            That is clear now. What remains is the data request.

            Comment


            • #7
              Click image for larger version

Name:	WhatsApp Image 2023-12-06 at 16.54.33.jpeg
Views:	2
Size:	41.7 KB
ID:	1736305


              Andrew Musau or Nick Cox This is an example of what i would like to graph. If you know any code that could work, i would really appreciate it!

              Comment


              • #8
                See #3 and #6.

                Comment


                • #9
                  Originally posted by Andrew Musau View Post
                  See #3 and #6.
                  Code:
                  * Example generated by -dataex-. For more info, type help dataex
                  clear
                  
                   parm               estimate             min95             max95             EventYear
                  "mmm_lag1"     .07552530030467329  .019821471292523977     .1312291293168226  -1
                  "mmm_lag2"     .04837949048408223  -.02148482601950996    .11824380698767442  -2
                  "mmm_lag3"   -.009232257148314053  -.06434084037389622    .04587632607726812  -3
                  "mmm_lag4"    .005353048913761499  -.03917912215450748    .04988521998203047  -4
                  "mmm_lag5"    .025377834894978014 -.032637473664793845    .08339314345474988  -5
                  "mmm_lag6"   -.010747433969394477  -.06804735774957821    .04655248981078925  -6
                  "mmm_lag7"   -.024166302985257758  -.07242269765010508    .02409009167958956  -7
                  "mmm_lag8"    .038258859553079935 -.017386149113534907    .09390386821969478  -8
                  "mmm_lag9"    -.01765988371076928  -.06775253815916632   .032432770737627764  -9
                  "mmm_lag10"  -.050472007714595334  -.10107487303377535 .00013085760458469292 -10
                  "mmm_lag11"   -.03633970910251658  -.09704977722289339    .02437035901786022 -11
                  "mmm_lag12"  -.016593292632622797  -.07648533037400085   .043298745108755254 -12
                  "mmm_lead1"     .0541361745144955 .0010030680696102093    .10726928095938079   1
                  "mmm_lead2"   .026124835813717835 -.027525205313104845    .07977487694054052   2
                  "mmm_lead3"   .039000081695277175  -.01278870191463724    .09078886530519159   3
                  "mmm_lead4"     .0162790456689507  -.06233532227319457    .09489341361109596   4
                  "mmm_lead5"     .0487698848682739 .0020986961036817756    .09544107363286602   5
                  "mmm_lead6"   .023473660603989182  -.02753545005302802    .07448277126100639   6
                  "mmm_lead7"    .05656554692888086 .0065795058495362185     .1065515880082255   7
                  "mmm_lead8"  .0045220839299597165 -.043525058915175587    .05256922677509502   8
                  "mmm_lead9"  -.030162258720697048  -.08114894258047113   .020824425139077035   9
                  "mmm_lead10"   .06753683379496829  .015489677776314818    .11958398981362175  10
                  "mmm_lead11"  .047624971510478654 -.010769717022778472    .10601966004373578  11
                  "mmm_lead12"  .026769469672705375 -.026686628566748395    .08022556791215915  12
                  end
                  Last edited by Jose Ignacio Torrealba; 06 Dec 2023, 15:24.

                  Comment


                  • #10
                    For example:

                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input str30(parm) double(estimate min95 max95 EventYear)
                    "mmm_lag1"     .07552530030467329  .019821471292523977     .1312291293168226  -1
                    "mmm_lag2"     .04837949048408223  -.02148482601950996    .11824380698767442  -2
                    "mmm_lag3"   -.009232257148314053  -.06434084037389622    .04587632607726812  -3
                    "mmm_lag4"    .005353048913761499  -.03917912215450748    .04988521998203047  -4
                    "mmm_lag5"    .025377834894978014 -.032637473664793845    .08339314345474988  -5
                    "mmm_lag6"   -.010747433969394477  -.06804735774957821    .04655248981078925  -6
                    "mmm_lag7"   -.024166302985257758  -.07242269765010508    .02409009167958956  -7
                    "mmm_lag8"    .038258859553079935 -.017386149113534907    .09390386821969478  -8
                    "mmm_lag9"    -.01765988371076928  -.06775253815916632   .032432770737627764  -9
                    "mmm_lag10"  -.050472007714595334  -.10107487303377535 .00013085760458469292 -10
                    "mmm_lag11"   -.03633970910251658  -.09704977722289339    .02437035901786022 -11
                    "mmm_lag12"  -.016593292632622797  -.07648533037400085   .043298745108755254 -12
                    "mmm_lead1"     .0541361745144955 .0010030680696102093    .10726928095938079   1
                    "mmm_lead2"   .026124835813717835 -.027525205313104845    .07977487694054052   2
                    "mmm_lead3"   .039000081695277175  -.01278870191463724    .09078886530519159   3
                    "mmm_lead4"     .0162790456689507  -.06233532227319457    .09489341361109596   4
                    "mmm_lead5"     .0487698848682739 .0020986961036817756    .09544107363286602   5
                    "mmm_lead6"   .023473660603989182  -.02753545005302802    .07448277126100639   6
                    "mmm_lead7"    .05656554692888086 .0065795058495362185     .1065515880082255   7
                    "mmm_lead8"  .0045220839299597165 -.043525058915175587    .05256922677509502   8
                    "mmm_lead9"  -.030162258720697048  -.08114894258047113   .020824425139077035   9
                    "mmm_lead10"   .06753683379496829  .015489677776314818    .11958398981362175  10
                    "mmm_lead11"  .047624971510478654 -.010769717022778472    .10601966004373578  11
                    "mmm_lead12"  .026769469672705375 -.026686628566748395    .08022556791215915  12
                    end
                    
                    g low =0
                    g high= .1
                    
                    #delimit ;
                    
                    graph twoway (rcap max95 min95 EventYear, mcolor(black) lcolor(black) lpattern(solid))
                    (scatter estimate EventYear, mcolor(black) lcolor(black) lpattern(solid) m(d) )
                    (rbar low high EventYear if EventYear>=1, fcolor(black%20) lc(none)),
                    graphregion(fcolor(white) lcolor(white) lwidth(vvvthin) ifcolor(white) ilcolor(white) ilwidth(vvvthin))
                    title( "{stSerif:{bf:Figure 1. {it:Event Study: cotiza_pension}}}", color(black) size(large))
                    xtitle("{stSerif:Meses Desde el Derecto de Ley Migración}") xscale(titlegap(2))
                    xline(0, lcolor(black) lpattern(dash)) legend(off)
                    yline(0, lcolor(black) lpattern(dash))
                    yline(-0.1 -0.05 0 0.05 0.1, lwidth(vvvthin) lpattern(dash) lcolor(black))
                    xlabel(#17,valuelabel nogrid)
                    note("{stSerif:{it:Notes}. OLS coefficient estimates (and their 95% confidence intervals) are reported.}"
                    "{stSerif: Especificación 2.}", margin(small)) ;
                    
                    #delimit cr
                    Click image for larger version

Name:	Graph.png
Views:	1
Size:	28.2 KB
ID:	1736318

                    Comment


                    • #11
                      Andrew Musau Thank you very much! And do you know how can I add an yline() but that starts from 0 (as the one in the photo, that is -0.017, in that case, starts in -1)

                      Comment


                      • #12
                        At y=.04 with twoway scatteri:

                        Code:
                        #delimit ;
                        
                        graph twoway (rcap max95 min95 EventYear, mcolor(black) lcolor(black) lpattern(solid))
                        (scatter estimate EventYear, mcolor(black) lcolor(black) lpattern(solid) m(d) )
                        (rbar low high EventYear if EventYear>=-1, fcolor(black%20) lc(none))
                        (scatteri .04 0.45 .04 12.5, recast(line) lc(red) lp(dash)),
                        graphregion(fcolor(white) lcolor(white) lwidth(vvvthin) ifcolor(white) ilcolor(white) ilwidth(vvvthin))
                        title( "{stSerif:{bf:Figure 1. {it:Event Study: cotiza_pension}}}", color(black) size(large))
                        xtitle("{stSerif:Meses Desde el Derecto de Ley Migración}") xscale(titlegap(2))
                        xline(0, lcolor(black) lpattern(dash)) legend(off)
                        yline(0, lcolor(black) lpattern(dash))
                        yline(-0.1 -0.05 0 0.05 0.1, lwidth(vvvthin) lpattern(dash) lcolor(black))
                        xlabel(#17,valuelabel nogrid) xsc(r(-12.5 12.5)) xlab(-12(2)12)
                        note("{stSerif:{it:Notes}. OLS coefficient estimates (and their 95% confidence intervals) are reported.}"
                        "{stSerif: Especificación 2.}", margin(small)) ;
                        
                        #delimit cr
                        Last edited by Andrew Musau; 06 Dec 2023, 19:30.

                        Comment


                        • #13
                          Thank you!! Andrew Musau

                          Comment

                          Working...
                          X