Announcement

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

  • Graphs: ylabel

    Hello!

    I'm trying to graph a twoway scatter, and the results appear at the bottom of the graph. I have been working fine with this type of graph, however after I changed the specification of it, all of the results appear at the bottom even if I change the ylabel of it.

    So, this is what I had before:

    Click image for larger version

Name:	DD_4b_mat.jpg
Views:	1
Size:	322.7 KB
ID:	1686729


    And after I changed the specification of the regression, I get this graph:
    Click image for larger version

Name:	Captura de Pantalla 2022-10-25 a la(s) 12.26.47.png
Views:	1
Size:	557.7 KB
ID:	1686730


    So this is my code:

    Code:
    areg prom_mate4b_rbd y1 y2 y3 y4 y5 y6 y7 y8 y9 t1 t2 t3 t4 t5 t6 t7 t8 treat, a(rbd)
    parmest, label for(estimate min95 max95 %8.2f) li(parm label estimate min95 max95) saving(mat4b_DD.dta, replace)
    use ./mat4b_DD.dta, replace
    
    keep in 10/18
    
    gen     year=2010 in 1
    replace year=2011 in 2
    replace year=2012 in 3
    replace year=2013 in 4
    replace year=2014 in 5
    replace year=2015 in 6
    replace year=2016 in 7
    replace year=2017 in 8
    replace year=2018 in 9
    
    twoway (scatter estimate year, mlabel(year) mlabsize(vsmall) msize(tiny)) (rcap min95 max95 year, msize(vsmall)), ytitle(Coeficiente SIMCE Matemáticas) yscale(titlegap(2)) yline(0, lwidth(vthin) lcolor(black)) xtitle(Años) xscale(titlegap(2)) legend(off)
    So, changing the ylabel:

    Code:
    areg prom_mate4b_rbd y1 y2 y3 y4 y5 y6 y7 y8 y9 t1 t2 t3 t4 t5 t6 t7 t8 treat, a(rbd)
    parmest, label for(estimate min95 max95 %8.2f) li(parm label estimate min95 max95) saving(mat4b_DD.dta, replace)
    use ./mat4b_DD.dta, replace
    
    keep in 10/18
    
    gen     year=2010 in 1
    replace year=2011 in 2
    replace year=2012 in 3
    replace year=2013 in 4
    replace year=2014 in 5
    replace year=2015 in 6
    replace year=2016 in 7
    replace year=2017 in 8
    replace year=2018 in 9
    
    twoway (scatter estimate year, mlabel(year) mlabsize(vsmall) msize(tiny)) (rcap min95 max95 year, msize(vsmall)), ytitle(Coeficiente SIMCE Matemáticas) yscale(titlegap(2)) yline(0, lwidth(vthin) lcolor(black)) ylabel(-30(10)35) xtitle(Años) xscale(titlegap(2)) legend(off)
    This is what I get:

    Click image for larger version

Name:	Captura de Pantalla 2022-10-25 a la(s) 12.30.35.png
Views:	1
Size:	129.1 KB
ID:	1686731


    So every result appears at the bottom of the graph.

    I would really appreciate your help guys!

  • #2
    Have you checked if you have a missings problem? Sometimes Stata defines the ranges of the axis before checking if some of the variables are missing, and you can get crazy axis ranges for apparently no reason because the missing observations are not shown in the graph.

    Comment


    • #3
      Originally posted by alejoforero View Post
      Have you checked if you have a missings problem? Sometimes Stata defines the ranges of the axis before checking if some of the variables are missing, and you can get crazy axis ranges for apparently no reason because the missing observations are not shown in the graph.
      Sorry that I didn't mention it before, but there aren't missing observations. There aren't missing observations before the regression and the after. The only "missing observation" (but it is 0) it's on the 2018, but that was on purpose.

      PD: I'm trying to test parallel trends before the program is applied

      Comment


      • #4
        Detail first: Your nine lines from
        Code:
         gen     year=2010 in 1
        to
        Code:
          replace year=2018 in 9
        could be just
        Code:
        gen year = 2009 + _n
        That aside please use
        Code:
        dataex estimate min95 max95 year
        for your reduced dataset to show us what the graph code is looking at. The main point here is likely to be that specifying a range on
        ylabel() or even ysc() will not itself shrink the graph. I guess that there is a large value for 2018 on one of those variables -- say max95 -- which can't be plotted because of a missing value elsewhere, but it is affecting the range of the graph.

        Comment


        • #5
          I made the same point as alejoforero and it continues to be my guess. You can show us we're wrong by giving the data, as requested.

          Strictly, it's values of a variable that may or may not be missing. An observation in Stata is a row in the dataset.

          Comment

          Working...
          X