1. Casey Dunn
  2. sicb2013

Commits

Casey Dunn  committed ffd27e1

streamlined convex minimization code

  • Participants
  • Parent commits 7e1943d
  • Branches master

Comments (0)

Files changed (2)

File functions.r

View file
 	return( trueCovariance ) 
 }
 
-
-Array2List <- function(A) {
-	s <- dim(A)
-	R <- vector("list", s[3])
-
-	for (j in 1:s[3]) {
-		R[[j]] <- A[,,j]
-	}
-	return(R)
-}
-
-
 plot_matrix <- function(m, ... ) {
 	
 	nr <- nrow(m)

File regularization.r

View file
 # Convex Minimization. arXiv.org (2011). http://arxiv.org/abs/1111.1133
 
 
-Zlist <- Array2List(Z)
-conlist <- lapply(Zlist, function(x) apply(x, 2, function(a) pic(a, phy)))
-
-relist.l <- lapply( conlist, function(x) {
-	re.lorec <- lorec(cor(x), diag(1, 100), diag(1, 100), sqrt(p/n), sqrt(log(p)/n))
-	re.lorec.eig <- eigen(re.lorec$L)
-	## threholding both
-	sel <- re.lorec.eig$values>sqrt(p/n)
-	if (sum(sel)>0) {
-		V <- re.lorec.eig$vectors
-		V <- V*(abs(V)>sqrt(1/p))
-		V <- V[,1:sum(sel)]
-		Lhat <- V%*%diag(re.lorec.eig$values[1:sum(sel)])%*%t(V)
-	} else {
-		Lhat <- matrix(0, p, p)
-	}
-	Shat <- re.lorec$S
-	Shat <- Shat*(abs(Shat)>sqrt(1/p))
-	Lhat + Shat
-})
-
-luo <- relist.l[[1]]
+re.lorec <- lorec( contrastcor, diag(1, 100), diag(1, 100), sqrt(p/n), 
+	sqrt(log(p)/n) )
+re.lorec.eig <- eigen( re.lorec$L )
+# threholding both
+sel <- re.lorec.eig$values > sqrt( p/n )
+if ( sum(sel) > 0 ) {
+	V <- re.lorec.eig$vectors
+	V <- V * ( abs(V)>sqrt(1/p) )
+	V <- V[ ,1:sum(sel) ]
+	Lhat <- V%*%diag( re.lorec.eig$values[1:sum(sel)] )%*%t(V)
+} else {
+	Lhat <- matrix(0, p, p)
+}
+Shat <- re.lorec$S
+Shat <- Shat*(abs(Shat)>sqrt(1/p))
+luo <- Lhat + Shat
 
 
 # Set up plotting parameters