Announcement

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

  • Special line graph

    Hello,

    I think I have a very simple question, but I can't find the answer.

    I have a dataset and I created a dummy.

    I'd like to plot the mean of the dummy over the years.

    I manage to do that with

    graph bar (mean) dummy, over(year)

    But I'd like to see the trend line instead of the bar chart. How can I do that?

    Corollary question: what if I'd like to plot two trends as the above in the same graph, i.e. what I now see typing graph bar (mean) dummy1, over(year) and graph bar (mean) dummy2, over(year) but as two lines in the same graph?

    Thanks!

  • #2
    You need to switch to twoway.

    Code:
    forval j = 1/2 { 
         egen mean`j' = mean(dummy`j'), by(year)
    } 
    
    twoway line mean? year, sort
    That's not a trend line (how do you define that? linear? quadratic? local polynomial? cubic spline?) but it's a basic line graph.

    Comment

    Working...
    X