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

st: Using results from correlation matrices to pinpoint variables


From   Alejandro Delafuente <[email protected]>
To   [email protected]
Subject   st: Using results from correlation matrices to pinpoint variables
Date   Thu, 16 Jun 2005 17:49:20 +0100 (BST)

Dear Statalisters,
I am running several correlations between a set of core variables (v1 v2 v3) 
and a list of other variables (v4 to v60). Once each correlation is run, I 
want Stata to select a variable from my core group if it satisfies two 
conditions: a) has the highest correlation coefficient among all (always 
plausible to find one), and b) have a coefficient above >.75. Thus, in my 
example below v2 would be the variable that i want. I don't know how to tell 
Stata to look for the variable when both conditions are met, and then use it 
for other purposes (ie, create a means ratio where the denominator would be the 
time mean for the selected variable), or do nothing when this is not the case.  
My subprogram below the correlation matrix is just to clarify my goal. I don't 
know if saving the matrix after each correlation and then referring to the 
outputs of the first column would be a possible way to pinpoint my variable. 
Any help on how to program this (if possible) would be very much appreciated.

corr v4 $othervars if _n>10
(obs=162)

             |       v4       v1       v2       v3
-------------+------------------------------------
          v4 |   1.0000
          v1 |   0.6307   1.0000
          v2 |   0.8028   0.7753   1.0000
          v3 |   0.7045   0.4304   0.5670   1.0000


forvalues i = 1/60 {
corr v`i' `othervars' //`othervars' includes v1 v2 and v3
gen ratio`i'=v`i' / x
// if x has the highest correlation with v`i' & corr>.75 // here v2

Many thanks!

Alejandro


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