|
|
|
||||
|
|
|||||
Here are a couple of examples of making spaghetti plots.
Here is a basic spaghetti plot that looks at "alcuse" over time (age_14) showing one regression line per person (see "findit spagplot")
spagplot alcuse age_14 , id( id )
Here we make the same graph manually.
use http://www.ats.ucla.edu/stat/stata/examples/alda/data/alcohol1_pp, clear quietly xi: regress alcuse i.id*age_14 predict yhat graph twoway line yhat age_14, connect(L L) And here is the graph
But say that you wanted to see separate lines for males and females. We can do that, as shown below.
use http://www.ats.ucla.edu/stat/stata/examples/alda/data/alcohol1_pp, clear separate alcuse, by(male) quietly xi: regress alcuse0 i.id*age_14 predict yhat0 quietly xi: regress alcuse1 i.id*age_14 predict yhat1 graph twoway line yhat0 yhat1 age_14, connect(L L)
and here is the graph
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services