search for: r2cut

Displaying 2 results from an estimated 2 matches for "r2cut".

Did you mean: r2cum
2008 May 17
1
Correlated Columns in data frame
.../ of Mr.Rajarshi Guha. The code is ################# r2test <- function(df, cutoff=0.8) { if (cutoff > 1 || cutoff <= 0) { stop(" 0 <= cutoff < 1") } if (!is.matrix(d) && !is.data.frame(d)) { stop("Must supply a data.frame or matrix") } r2cut = sqrt(cutoff); cormat <- cor(d); bad.idx <- which(abs(cormat)>r2cut,arr.ind=T); bad.idx <- matrix( bad.idx[bad.idx[,1] > bad.idx[,2]], ncol=2); drop.idx <- ifelse(runif(nrow(bad.idx)) > .5, bad.idx[,1], bad.idx [,2]); if (length(drop.idx) == 0) { 1:ncol(d) }...
2003 Nov 21
3
speeding up a pairwise correlation calculation
...tion later) The code I am using is: ndesc <- length(names(data)); for (i in 2:(ndesc-1)) { for (j in (i+1):ndesc) { if (i %in% drop || j %in% drop) next; r2 <- cor(data[,i],data[,j]); r2 <- r2*r2; if (r2 >= r2cut) { rnd <- abs(rnorm(1)); if (rnd < 0.5) { drop <- c(drop,i); } else { drop <- c(drop,j); } } } } drop is a vector that contains columns numbers that can be skipped data is the data.frame For the data.frame mention...