Announcement

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

  • Changing the Y axis scale on a twoway graph

    Hi all,
    I am trying to graph raw trends to show parallel trends for a DiD estimation. Now for the unadjusted trends, I do not need to run the regression, so I was using separate and graph to generate the parallel trend graphs. However, since the point estimates of the excercise is very small, it does not visibly show up on the graph. My understanding is that if I rescale the Y axis, I might be able to show the changes. Is there a way to rescale the axis. I used
    Code:
    preserve
    separate drinkalcohol, by(Bihar)
    collapse (mean) drinkalcohol? , by(Bihar Year)
    graph twoway line drinkalcohol? Year, sort
    restore
    to generate the graphs.
    Here Bihar is basically the group assignment and Year is the 3 years for which data was collected. In fact 1 stands for 2003, 2 stands for 2014 and 3 stands for 2019. so my typical regression for the DiD would be
    Code:
    reg drinkalcohol i.Bihar##i.Post i.Year
    Post is 1 for Year = 3 and 0 otherwise
    Here's a data example
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(Bihar Year) byte drinkalcohol
    0 3 0
    0 3 0
    1 2 0
    0 1 0
    0 3 0
    1 2 0
    0 2 0
    0 1 0
    0 3 0
    1 3 0
    0 1 0
    0 1 0
    0 3 0
    0 2 0
    1 3 0
    0 3 0
    0 2 0
    1 2 0
    1 3 0
    0 1 0
    1 3 0
    0 3 0
    1 3 0
    0 1 0
    0 3 0
    0 2 0
    1 3 0
    1 3 0
    0 3 0
    0 1 0
    0 2 0
    0 2 0
    1 3 0
    0 3 0
    0 2 0
    0 2 0
    0 3 0
    0 3 0
    1 3 0
    0 3 0
    0 3 0
    1 3 0
    0 2 0
    0 2 0
    0 2 0
    0 1 0
    0 2 0
    0 2 0
    0 2 0
    1 2 0
    0 2 0
    0 1 0
    0 2 0
    0 2 0
    0 2 0
    1 2 0
    0 2 0
    0 1 0
    1 1 0
    0 2 0
    0 3 0
    0 2 0
    0 2 0
    0 2 0
    0 2 0
    0 2 0
    1 2 0
    0 3 0
    0 1 0
    0 3 0
    0 2 0
    0 2 0
    0 3 0
    0 3 0
    1 3 0
    0 1 1
    0 3 0
    1 2 0
    1 1 0
    1 2 0
    0 1 0
    0 2 0
    1 3 0
    0 2 0
    1 2 0
    1 2 0
    1 2 0
    1 2 0
    0 3 0
    1 3 0
    0 3 0
    0 3 0
    0 1 0
    0 2 0
    1 2 0
    0 2 1
    0 1 0
    0 2 0
    1 2 0
    0 1 1
    end
    label values drinkalcohol S720
    label def S720 0 "no", modify
    label def S720 1 "yes", modify
    Last edited by Rajdeep Chaudhuri; 27 Jan 2025, 02:56.

  • #2
    In your data example, one variable's means are always 0, so the scope for changing the scale usefully seems limited.

    In your full dataset, if all means are positive and some are very small, changing to logit scale could be a good idea. The summaries concerned are proportions after all. (What that implies for your methodology using plain regression I take to be a larger question.)

    More discussion at

    SJ-8-1 gr0032 . . . . . . . Stata tip 59: Plotting on any transformed scale
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
    Q1/08 SJ 8(1):142--145 (no commands)
    tip on how to graph data on a transformed scale

    Stata Tip 59: Plotting on Any Transformed Scale

    Comment


    • #3
      Hi Nick, thanks for the response
      I tried using
      Code:
      gen logit_drinkalcohol =  logit(drinkalcohol)
      but stata gives me
      Code:
      . gen logit_drinkalcohol =  logit(drinkalcohol)
      drinkalcohol ambiguous abbreviation
      r(111);

      Comment


      • #4
        The function logit() may be useful if and only if applied to values between 0 and 1, but not 0 and 1. Otherwise put, I am suggesting it only for means greater than 0 and less than 1.

        Otherwise your code is failing for the reason stated: two or more variable names abbreviate ambiguously to the name you give,

        Comment

        Working...
        X