Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

re: st: simple (?) graph question


From   David Airey <david.airey@vanderbilt.edu>
To   statalist@hsphsun2.harvard.edu
Subject   re: st: simple (?) graph question
Date   Sat, 17 Apr 2004 11:58:30 -0500

Maybe "spaghplot" from ATS UCLA might be of interest too:

------------------------------------------------------------------------ -------
help for spagplot
------------------------------------------------------------------------ -------

Spaghetti Plot

spagplot yvar xvar [if exp] [in range], id(idvar) [nofit] [graph
options]

where yvar xvar are the Y and X variables you wish to plot and idvar is
the variable that identifies a single observation. Description

spagplot allows you to "spaghetti plot", i.e. a plot of an X variable and
the predicted values for the Y variable forming a regression line of the
predicted values of Y by X. A separate regression line is plotted for
each observation indicated by the idvar variable.

If you specify the nofit option, the actual y values (not the fitted y values
will be plotted.

Examples

We will show a number of examples from a data file which contains alcohol
use alcuse at 3 ages, age 14, 15, and 16 for a number of children
(identified by the variable id. The age variable has been centered
around age 14 and is named {id:age_14}. We first show how to obtain the
data file.

. use http://www.ats.ucla.edu/stat/stata/examples/alda/data/alcohol1_pp

This example shows a basic spaghetti plot of alcohol use by age, broken
down by id.

. spagplot alcuse age_14 , id( id )

This example just performs the plot for the first 30 observations.

. spagplot alcuse age_14 in 1/30, id( id )

This example shows the plot just for the ids below 9.

. spagplot alcuse age_14 if id <= 9, id( id )

This example adds a title as a graph option.

. spagplot alcuse age_14 , id( id ) ytitle("Predicted Alcohol Use")

This example adds a title as a graph option, and changes the scheme to
sj.

. spagplot alcuse age_14 , id( id ) ytitle("Predicted Alcohol Use") scheme(sj)

This example also changes the note from the default note.

. spagplot alcuse age_14 , id( id ) ytitle("Predicted Alcohol Use") scheme(sj)
> note("My custom note")

This example removes the note from the graph entirely.

. spagplot alcuse age_14 , id( id ) ytitle("Predicted Alcohol Use") scheme(sj)
> note("")


If you have comments or suggestions, please email Michael Mitchell at
mnm@@ucla.edu .

Author

Michael N. Mitchell
Statistical Computing Group
UCLA, Academic Technology Services
mnm@@ucla.edu

Also see

Manual: [R] graph

Online: help for graph

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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   |   What's new   |   Site index