Announcement

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

  • Why won't STATA properly scale the y axis in my event study graph?

    Hello all. I am but a lowly student who's way out of his depth dancing a complicated tango with a computer software which, much like the women I try to dance with on a night out, I find beautiful but impossible to understand. I am therefore a great admirer of the wizards on here who seemingly had an answer to every stata question about this godforesaken programme I could ask long before ChatGPT was a thing. Today is finally the day I popped my Stata forum cherry and decided to ask here what I cannot find on here from before.

    I am trying to create an event study graph but whatever I try in terms of what I can find on the internet about scaling y axes stata keeps giving me the same output, with axes that are significantly longer than all coefficients and confidence intervals. Does anyone know how to fix this? I've tried all the usual yscale, yrange etc codes and have even tried turning the values into z scores to no avail.

    Code:
    reg childcareindex malehadbaby2016 malehadbaby2017 malehadbaby2018 malehadbaby2020 malehadbaby2021 malehadbaby2022 malehadbaby2023 male hadbaby2016 hadbaby2017 hadbaby2018 hadbaby2020 hadbaby2021 hadbaby2022 hadbaby2023, cluster(nomem_encr)
    
    mat B = r(table)
    mat B = B'
    svmat B, names(col)
    replace b = 0 in 8
    replace ul = 0 in 8
    replace ll = 0 in 8
    replace b = 0 in 16
    gen event1_time = 2016 in 1
    replace event1_time = 2017 in 2
    replace event1_time = 2018 in 3
    replace event1_time = 2019 in 8
    replace event1_time = 2020 in 4
    replace event1_time = 2021 in 5
    replace event1_time = 2022 in 6
    replace event1_time = 2023 in 7
    twoway rcap ul ll event1_time || scatter b event1_time, sort(event1_time) xline(2019.5, lpattern(dash) lcolor(blue)) xline(2021.5, lpattern(dash) lcolor(red)) yline(0, lpattern(solid))

  • #2
    Spelling advice: Stata, godforsaken. The mildly sexual (and sexist) banter here doesn't create a good impression, to be frank, but then many people here probably don't get my sense of humour either.

    We can't see your data or your graph. You are plotting r ll ul and the only detail I can glean is that their values include 0.

    You are plotting against event_time which has values 2016(1)2023.

    Simple experiments such as

    Code:
    clear
    set obs 8
    gen event_time = 2015 + _n
    gen foo = 42
    line foo event_time
    suggest that Stata will produce x axis labels 2016(2)2024. Without any instructions from you, it is trying its best guess at a compromise between too many labels, too few labels, and wanting nice numbers, where nice is a technical term with a definition. More at https://journals.sagepub.com/doi/pdf...6867X221141058 -- except that life is too short for you to read that.

    Just spell out to Stata exactly which axis labels you want. If this were my problem, my inclination would be to want all the years with data labelled and no others and to think I have enough space to do that.

    Code:
    xla(2016/2023)
    as an extra option would do that. We can't see exactly what you tried with e.g. yscale() but the documented limit on that is that it never restricts the range over and above what ylabel() does on your behalf. I remain optimistic that specifying ylabel() directly should help.
    Last edited by Nick Cox; 16 Jan 2025, 04:46.

    Comment

    Working...
    X