Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to store correlate result using stata 9


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: How to store correlate result using stata 9
Date   Wed, 23 May 2007 07:34:36 +0100 (BST)

--- hai guo <[email protected]> wrote:
> I want to store the correlation coefficient into a
> variable. After I run corr var1 var2 var3
> i see the correlation coefficient output table. I
> searched online and it is said the correlate result
> should be stored in matrix rho(r), but when I tried in
> stata 9. I can't find it. 

You can get a list of what is stored and how it is named after a
command by typing -return list- (and -ereturn list- after estimation
commands). That shows you that -correlate- doesn't store the
correlation matrix but only the correlation between the first two
variables. (If you want the matrix you can look at
http://www.stata.com/support/faqs/stat/rho.html )
Typically storing a constant as a variable is a bad idea, but the
example below shows you how to do that. A better way is to use a local,
see: -help local-. Again the example below illustrates how that is
done.

*----------- begin example ---------
sysuse auto, clear
corr price mpg weight
return list
di r(rho)
gen rho = r(rho)   /*create the variable*/
local rho = r(rho) /*create the local*/
di `rho'
*----------- end example ------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


		
___________________________________________________________ 
Inbox full of unwanted email? Get leading protection and 1GB storage with All New Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index