[R] if ((x >.2 || x<(-.2)) && (col(x)!=row(x))) {x=x[,-col(x)]}
onyourmark
william108 at gmail.com
Fri May 8 07:39:22 CEST 2009
Hi. I have a correlation matrix 'x' which is of size 923x923
I need to remove variables that are highly correlated. I don't have a
sophisticated way of selecting which of the two in a highly correlated pair
to remove. I thought I would just go through each entry of the correlation
matrix and if it is greater than 0.6 (or less than -0.6) I will remove that
column and then redo the check from scratch with the matrix (where now the
matrix has one less column).
As a test, I tried if ((x >.2 || x<(-.2)) && col(x)!=row(x)) {x=x[,-col(x)]}
but it does not remove any columns.
Also, I realized that I actually need to pull out the row that is associated
with that variable as well, and so perhaps the section inside {} needs to be
something like:
{x=x[-col(x),-col(x)]
Any idea on how to do this?
Thank you.
--
View this message in context: http://www.nabble.com/if-%28%28x-%3E.2-%7C%7C-x%3C%28-.2%29%29----%28col%28x%29%21%3Drow%28x%29%29%29-%7Bx%3Dx-%2C-col%28x%29-%7D-tp23440419p23440419.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list