Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Maarten Buis <maartenlbuis@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: twoway scatter plot -- how to show the regression equation in the legend |
Date | Tue, 17 Sep 2013 10:30:12 +0200 |
On Tue, Sep 17, 2013 at 9:56 AM, Alice Guerra wrote: > I was wondering if it is possible to compute and show in the legend > the regression line in a twoway scatter plot with lfit. *------------------ begin example ------------------ sysuse auto reg price mpg local eq "`e(depvar)' =" local eq "`eq' `: display %7.0g _b[_cons]'" local eq "`eq' `=cond(_b[mpg] > 0, "+", "-")'" local eq "`eq' `: display %5.0g abs(_b[mpg])' mpg" twoway lfit price mpg || /// scatter price mpg, /// legend(order(1 2 - "`eq'")) *------------------- end example ------------------- * (For more on examples I sent to the Statalist see: * http://www.maartenbuis.nl/example_faq ) Hope this helps, Maarten --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/