M_Sundaram
10-12-2010, 05:05 AM
I'm having trouble constructing a line graph. Before you leave this thread immediately, let me explain:
1) I'd like to graph the AVERAGES of a binary variable over time.
2) I'd like to calculate these averages for a given number of time bins. I have 260 weeks' worth of data and I would like to graph, for example, the average of this binary variable in weeks 1-10, in weeks 11-20, and so on.
I've tried using egen to calculate the mean of the binary variable by week group but Stata doesn't like me trying to use egen at the same time that I use another time variable generated using the xtile command. I end up with a list of 39,000 values that are all the same, which is unhelpful.
Is there a way I can get around this without manually calculating the averages for each time bin, entering them in a word processor, and graphing the whole thing by hand?
Thanks for your help and patience with this relative Stata newbie.
1) I'd like to graph the AVERAGES of a binary variable over time.
2) I'd like to calculate these averages for a given number of time bins. I have 260 weeks' worth of data and I would like to graph, for example, the average of this binary variable in weeks 1-10, in weeks 11-20, and so on.
I've tried using egen to calculate the mean of the binary variable by week group but Stata doesn't like me trying to use egen at the same time that I use another time variable generated using the xtile command. I end up with a list of 39,000 values that are all the same, which is unhelpful.
Is there a way I can get around this without manually calculating the averages for each time bin, entering them in a word processor, and graphing the whole thing by hand?
Thanks for your help and patience with this relative Stata newbie.