Help the Stat Consulting Group by giving a gift

How do I use version 7 graph commands in later versions of Stata?

and say that you wanted to see the scatterplot and regression line betweenuse http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear

And you would get a graph that looks something like this.regress write read predict yhat graph write yhat read, twoway symbol(oi) connect(.l) jitter(2) sort

But if you execute the graph command in Stata version 8 or later you get this error message.

You get this error message because the syntax of thewritegraph_g.new yhat read, twoway symbol(oi) connect(.l) jitter(2) sort: class member function not found write is not a valid graph subcommand r(198);

There are two ways that you can deal with this. You can instruct Stata to run the command as though you were using Stata version 7 (instead of a later version) or you can convert the command to use the newer syntax. We discuss both below.

and this produces a graph that looks just like you were using Stata version 7. Another trick is to use thegraph7 write yhat read, twoway symbol(oi) connect(.l) jitter(2) sort

and again this produces a graph that looks just like you were using Stata version 7. If you are going to run a series ofversion 7: graph write yhat read, twoway symbol(oi) connect(.l) jitter(2) sort

The strategy you choose will depend on the situation. These strategies work the same way in the Stata command window or in a Stata .do file.version 7 graph write yhat read, twoway symbol(oi) connect(.l) jitter(2) sort graph write graph read version 8 /* or 9 or 10 */

It is not possible to cover all of the different ways in which the current Stata graphics commands differ from the Stata 7 commands. However, it is possible to give suggestions that cover many commonly encountered situations. To completely cover the topic we would refer you to the resources at the Stata Topics: Graphics (including Stata Online Graphics Manual, via the Stata web site).

The current Stata

Thegraph twowayscatterplots, line plots, etc.graph matrixscatterplot matricesgraph barbar chartsgraph dotdot chartsgraph boxbox and whisker plotsgraph piepie charts

Thus, a scatterplot can be done three different ways:scatterscatterplotlineline plotconnectedconnected-line plotarealine plot with shadingspikespike plotdotdot plotlowessLOWESS line plotlfitlinear prediction plotqfitquadratic prediction plotlfitcilinear prediction plot with CIsqfitciquadratic prediction plot with CIsfunctionline plot of functionhistogramhistogram plotkdensitykernel density plot

However, if you want to combine severalgraph twoway scatter write read twoway scatter write read scatter write read

All of these constructions produce a graph that looks like this.graph twoway (scatter write read, jitter(2)) (lfit write read, sort ) twoway (scatter write read, jitter(2)) (lfit write read, sort ) graph twoway scatter write read, jitter(2) || lfit write read, sort twoway scatter write read, jitter(2) || lfit write read, sort

Note this will not work:

Note: The separate plots indicated by enclosing the specific command in parentheses "()" or by separating the commands with two vertical bars "||".(scatter write read) (lfit write read)

Note that, in both,graph write yhat read, twoway symbol(oi) connect(.l) jitter(2) sort

The above comments cover only a few of the many ways in which the current version of Stata graphics differ from the Stata 7 version. It is well worth you time to sit down and read the Stata Online Graphics Manual and see the Stata Topics: Graphics.scatter write yhat read, msymbol(o i) connect(. l) jitter(2) sort

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.