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

st: uncentered correlation


From   Gerson Dushnitsky <[email protected]>
To   [email protected]
Subject   st: uncentered correlation
Date   Sat, 10 Jan 2004 15:12:56 -0500

Hi guys,

I would appreciate it if you can help me with the following:

Is there any easy way to calculate UNCENTERED correlation in Stata?

In particular, I have a matrix and I am interested in calculating the
uncentered correlation between the different columns.
Currently, I have written a code that calculates the (regular -- i.e.,
Pearson's) correlation (fyi -- see below).

Thanks,
Gary

Calculating correlation in a matrix:
  matrix B=J(43,43,0)
  local i=1
  while `i' <=43 {
                  local j=1
                  while `j'<= 43 {
                          corr mfctr`i' mfctr`j'
                          if r(rho) ~=. {matrix B[`i',`j']=r(rho)}
                          else {matrix B[`i',`j']=9}
                          local temp=0
                          local j=`j'+1
                              }
                  local i=`i'+1
              }

  svmat B




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