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]

RE: st: twoway graph, with by and combine


From   "Hoffman, George" <ghoffman@mcw.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: twoway graph, with by and combine
Date   Sun, 1 May 2011 10:12:49 -0500

Thank you Eric. I'll build a wrapper for this since I would like to issue this repetitively for the dataset.

George


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Eric Booth
Sent: Sunday, May 01, 2011 10:01 AM
To: <statalist@hsphsun2.harvard.edu>
Subject: Re: st: twoway graph, with by and combine

<>

You can specify each line separately with an -if-:
************
 sysuse auto, clear
 tw (lfit price mpg if rep78==1) (lfit price mpg if rep78==2) ///
  (lfit price mpg if rep78==3, lpattern(dash)) (lfit price mpg if rep78==4, lpattern(dot))

**
**or build the command using macros 
**** to avoid manually typing all categories of your ID:

 levelsof rep78, loc(ll)
 foreach v in `ll' {
 	loc gr (lfit price mpg if rep78==`v')  `gr'
 	}

tw (scatter price mpg) `gr' ,  ///
/* you can differentiate the lines by 
changing the lpatterns,
or you can edit the label 
with an option like: */ ///
 	legend(on order(1 "Dots" 2 "Rep78 Category 2" 3 "three"))
************

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754


On May 1, 2011, at 9:44 AM, Hoffman, George wrote:

> I've got panel data  and want to display the by(id) linear fit lines  on one graph.
>         twoway (fit y x, by(id)) 
> works, but gives different plots for all id's.  combine is not an option for by in this command.
> 
> Is there a quick way, or user-written way, to get the above on one graph? 
> Seems simple, but I can't find it.
> Thank you in advance
> George Hoffman
> 
> *
> *   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/




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

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