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

RE: st: Superimposing graphs


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Superimposing graphs
Date   Thu, 10 Feb 2005 20:45:54 -0600

I am not sure why this didn't work.  Using the auto data set, the comparable
commands would be 

twoway (scatter mpg weight if fore == 0) ///
(qfit mpg weight if fore == 0) ///
(scatter mpg weight if fore == 1 ) ///
(qfit mpg weight if fore == 1)

which works fine for me.

However, like your example, this returns an error:

twoway (scatter mpg weight if fore == 0 || qfit mpg weight if fore == 0) ///
(scatter mpg weight if fore == 1 || qfit mpg weight if fore == 1)

0| invalid name
invalid syntax
r(198);

Though if we do just one set of -twoway (scatter...|| qfit...)- it works.

Again, I think the problem binding () and separating ||.  Either notation
works, but combining doesn't seem like a good idea.

When it gets to capture -noi .Graph : .twowaygraph_g.new- (-set trace on-
for all the details) it appears the outer set of parentheses is stripped.
So 

twoway (scatter mpg weight if fore == 0 || qfit mpg weight if fore == 0)

becomes essentially -twoway scatter... || qfit...- :

= capture noi .Graph : .twowaygraph_g.new scatter mpg weight if fore == 0 ||
qfit mpg weight if fore == 0 


In this syntax:

twoway (scatter mpg weight if fore == 0 || qfit mpg weight if fore == 0) ///
(scatter mpg weight if fore == 1 || qfit mpg weight if fore == 1)

there are no outer parentheses 

= capture noi .Graph : .twowaygraph_g.new (scatter mpg weight if fore == 0
|| qfit mpg weight if fore == 0) (scatter  mpg weight if fore == 1 || qfit
mpg weight if fore == 1)
0| invalid name

And so it is views each ( ) as one command.

Of course, none of the above may be correct, but it is how I read the log
file. 

The moral seems to be don't try to bind() what should be separated||


Scott



> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Branko Milanovic
> Sent: Thursday, February 10, 2005 3:35 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: Superimposing graphs
> 
> 
> Scott,
> 
> Unfortunately, it does not work.  What I find strange is that
> 
> twoway (scatter capture lngdpppp if year==1988 & group==1 || qfit
> capture lngdpppp if year==1988 & group==1)
> 
> Works quite fine. But if I repeat the same thing for another year (on
> the same figure) it does NOT work. But then if I take that another year
> and plot it alone (just to check if something may be wrong with it), the
> graph works again. O, it is only when they are together that the things
> do not work. (On a related note, it seems to me that the new twoway
> options have a fair number of bugs.)
> 
> Best, b
> 


*
*   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