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

st: RE: Linear regression, correlation coefficient and Stat 8 Graphs


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Linear regression, correlation coefficient and Stat 8 Graphs
Date   Fri, 30 Apr 2004 15:26:24 +0100

It is often simplest just to run -correlate- and then 
put a suitably rounded result in some title. 

However, the following shows how this could be 
automated more: 

. sysuse auto 
. gen gpm = 1 / mpg 
. corr gpm weight 
. local corr : di %5.3g r(rho) 
. twoway lfit gpm weight || scatter gpm weight , subtitle("correlation `corr'") 

Nick 
n.j.cox@durham.ac.uk 

Oliver Morgan
> 
> I have produced a twoway scatter plot to which I have fitted a linear
> prediction plot using the lfit option in Stata 8.
> 
> However, I would also like to present the correlation 
> coefficient (r) on
> this graph.

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