[R] Select set of variables with strongest correlation
nyk
nick at nyk.ch
Wed Jul 22 02:36:57 CEST 2009
Thanks, I did! This reply I also got helped a lot:
r<-matrix(rnorm(30),ncol=3)
r4 <-1+2*rnorm(10,r[,3], 0.5)
r5 <-1-3*rnorm(10,r[,3], 0.5)
data<-cbind(r,r4,r5)
corr<-cor(data,use='na.or.complete')
corrl<-(corr[col(corr)>row(corr)])^2
colms<-col(data)[col(col(data))>row(col(data))]
rows<-row(data)[col(row(data))>row(row(data))]
tosort<-cbind(corrl,rows,colms)
sorted <- tosort[order(tosort[,1],decreasing = TRUE, na.last = TRUE), ]
Uwe Ligges-3 wrote:
>
> See ?cor
>
> Uwe Ligges
>
>
> nyk wrote:
>> What would be a good method to find the subset of columns of a data
>> matrix
>> (with about 200 rows and columns) that has the strongest correlation to
>> one
>> other column? I tried testing sub-matrices with random sets of 10 columns
>> selected using lm(x ~submtrx) and comparing the r^2 values. But isn't
>> there
>> a better method for this task?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
View this message in context: http://www.nabble.com/Select-set-of-variables-with-strongest-correlation-tp24507332p24598197.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list