Commits

Casey Dunn committed 6390c84

moved thresholding to a function

Comments (0)

Files changed (2)

+
+#' regularization_by_thresholding
+#' 
+#' Regularizes a correlation matrix by thresholding
+#' 
+#' @param cor_matrix A correlation matrix
+#' 
+#' @param n The number of independent observations that were used to construct 
+#' the 
+#' 
+#' @return The regularized correlation matrix
+#' 
+#' @references
+#' Bickel, P. J. & Levina, E. Covariance regularization by thresholding. 
+#' Ann. Statist. 36, 2577–2604 (2008). http://dx.doi.org/10.1214/08-AOS600 
+#' 
+regularization_by_thresholding <- function ( cor_matrix, n ) {
+	# Regularization by thresholding
+	# Bickel, P. J. & Levina, E. Covariance regularization by thresholding. 
+	# Ann. Statist. 36, 2577–2604 (2008). http://dx.doi.org/10.1214/08-AOS600
+	
+	p <- ncol( cor_matrix )
+	
+	regularized <- cor_matrix * ( abs(cor_matrix) > sqrt(log(p)/n) )
+	
+	return( regularized )
+}
+
+regularization_by_convex_minimization <- function (cor_matrix) {
+
+	
+	return( luo )
+}
+
+
+
 test_cov_matrix <- function() {
 	# Builds a simple character covariance matrix for simulating data
 	
 
 contrastcor <- cor.table(contrasts)$r
 
-p <- ncol( contrasts )
 n <- nrow( contrasts )
 
 # Regularization by thresholding
-# Bickel, P. J. & Levina, E. Covariance regularization by thresholding. 
-# Ann. Statist. 36, 2577–2604 (2008). http://dx.doi.org/10.1214/08-AOS600
 
-bickel <- contrastcor * ( abs(contrastcor) > sqrt(log(p)/n) )
+bickel <- regularization_by_thresholding( contrastcor, n )
 
 # Regularization by convex Minimization
 # Luo, X. High Dimensional Low Rank and Sparse Covariance Matrix Estimation via 
 # Convex Minimization. arXiv.org (2011). http://arxiv.org/abs/1111.1133
 
+p <- ncol( contrastcor )
 
 re.lorec <- lorec( contrastcor, diag(1, 100), diag(1, 100), sqrt(p/n), 
 	sqrt(log(p)/n) )