Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: graphing the lines of the mean for a varaible by groups over time


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: graphing the lines of the mean for a varaible by groups over time
Date   Fri, 12 Mar 2010 18:11:30 -0000

Nothing in your code instructs Stata to work with means. You are
instructing Stata to plot all the values for all the panels. You should
not be surprised that it does precisely that. 

There are various ways to proceed. One is to -collapse- to means and
then plot the results. 

Nick 
n.j.cox@durham.ac.uk 

Mandy fu

I have a question of graphing the lines of a variable  by groups over
time on a three-period panel data set.

I have an  unbalanced 3-period panel data set, where the observations
are divided into four racial groups. I would like to plot the
predicted value of Y (which is variable Y_hat, results from previous
regression of Y on X variables) by racial groups over the three
periods.

The X-axis measures time, 1,2,3;
The Y-axis measures Y-hat.
In the graph there are four lines, repenting the four racial groups,
which measure the mean Y_hat for a particular group at each time.

The data set is as following:
------------------------------------------------------------
ID    Y_hat   time    race        Y    X1      X2
1      1.22     1         1
1      2.03     2         1
1      3.00     3         1
2      1.45     1         2
2      2.67     2         2
2     missing 3         2
------------------------------------------------------------
I tried the following syntax:
------------
      line Y_hat time if race==1 ,c(L)  ///
||    line  Y_hat time if race==2 ,c(L)  ///
||    line  Y_hat time if race==3 ,c(L)  ///
||    line Y_hat time if race==1 ,c(L)   ///
|| , title("plotting")
---------------
The graph from the above syntax includes lots of lines, which is not
what I would like to see.

I think I must misunderstood something here. I would appreciate if you
could give me some suggestions.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index