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: graph: how to draw 45 degree reference line


From   <Stefan.Gawrich@hlpug.hessen.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: graph: how to draw 45 degree reference line
Date   Mon, 15 Mar 2010 10:23:47 +0100

Hi Statalisters,

Friedhelm Huebler wrote: 

-line price price- is easy but depending on the resolution of the
display the line will not appear entirely straight. The appearance
also depends on how the data are sorted. -function- with the option
n(2) yields a cleaner graph. The setting of the range can be
automated.

. sysuse auto, clear
. sum price, meanonly
. local xmin = r(min)
. local xmax = r(max)
. twoway (scatter weight price) (function y=x, range(`xmin' `xmax')
n(2)), aspect(1)


****

I think, - twoway lfit - is best in this case:

// Line from min to max:
. twoway scatter weight price || lfit price price, aspect(1) range(. .) n(2)

// Line from 0 to max:
. twoway scatter weight price || lfit price price, aspect(1) range(0 .) n(2)

The "range" option of - lfit - is more versatile. 
Friedhelm Hueblers "n(2)" trick works with - lfit - 


Regards

Stefan Gawrich
HLPUG
Dillenburg
Germany




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