Announcement

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

  • Graph time-outcome comparing ages

    Good morning,
    I was tryinng to make a similar graph on stata, but could not be abble to do it, anybody can help me with the code?
    I would like to make a graph with similar lines (that differ by age of the individual), time would still be years, and my y axis is a dummy variable. I don't know if it's relevant but my data is panel.

    Thanks in advance!!!
    Click image for larger version

Name:	grafico dem.png
Views:	1
Size:	88.1 KB
ID:	1761345

  • #2
    A similar graph calls for twoway line directly or indirectly.

    To say anything more would require speculation on your variables, data layout, and so forth -- on which there is almost no information here.

    Also, if you want the y axis to show a dummy variable, that implies that each line jumps back and forth between 0 and 1. Now my guess is that you don't really mean that, but again what you do mean is not clear. From the mention of panel data I guess you want some reduction of the data.

    Also, you want help with your code but don't show any, so how can we do that?

    From inspection it is clear that the graph does not show percents that add to 100, but rather (I guess) the percent of people who do or are something else, according to ethnicity, gender and age.

    Wanting a similar graph provokes the question of whether a better graph can be imagined.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      A similar graph calls for twoway line directly or indirectly.

      To say anything more would require speculation on your variables, data layout, and so forth -- on which there is almost no information here.

      Also, if you want the y axis to show a dummy variable, that implies that each line jumps back and forth between 0 and 1. Now my guess is that you don't really mean that, but again what you do mean is not clear. From the mention of panel data I guess you want some reduction of the data.

      Also, you want help with your code but don't show any, so how can we do that?

      From inspection it is clear that the graph does not show percents that add to 100, but rather (I guess) the percent of people who do or are something else, according to ethnicity, gender and age.

      Wanting a similar graph provokes the question of whether a better graph can be imagined.
      I'm sorry I have done just a couple of posts here, I'm not yet good at posting.
      Anyways I will provide more context and code I've made. The outcome of my analysis is transition into adulthood (the dummy indicates whether the individual has transitioned or not), I would like to have this outcome on the years (time), and want the lines to describe individuals aged 20, individuals aged 30, individuals aged 40. I have tried using twoway line in this way: twoway (line dummy_transition year if age==20) (line dummy_transition year if age==30) (line dummy_transition year if age==40), anyways the resulting graph is not as expected. I attach a screenshot for individuals aged 20 just to give an idea.

      Hope now the information are enough, if anything else is needed I will be more than happy to provide addittional information.
      Click image for larger version

Name:	graph statalist .png
Views:	1
Size:	51.5 KB
ID:	1761436

      Comment


      • #4
        Hi Giorgio,
        this thread might help you: https://www.statalist.org/forums/for...-two-way-graph
        Alternatively, you could run a regression with your transition dummy as the dependent and an interaction of the year and age (group?) indicators as the explanatory variables, then compute the margins of the interaction, and plot the result with marginsplot.

        Comment


        • #5
          https://www.statalist.org/forums/help#stata gives advice about giving us (in this case)

          1. a data example

          2. code

          3. graph produced by data 1 and code 2.

          I have to guess wildly that you're expecting some kind of average or aggregation over panel data, whereas the code you give will best superimpose data for individuals. (It doesn't make complete sense either because a graph with three time series would usually show three different colours.)

          Do individuals revert to childhood as implied by line segments from 1 to 0?

          Comment

          Working...
          X