construction lasso rank
authorBenjamin Goehry <benjamin.goehry@math.u-psud.fr>
Tue, 17 Jan 2017 08:37:32 +0000 (09:37 +0100)
committerBenjamin Goehry <benjamin.goehry@math.u-psud.fr>
Tue, 17 Jan 2017 08:37:32 +0000 (09:37 +0100)
src/test/generate_test_data/helpers/constructionModelesLassoRank.R [new file with mode: 0644]

diff --git a/src/test/generate_test_data/helpers/constructionModelesLassoRank.R b/src/test/generate_test_data/helpers/constructionModelesLassoRank.R
new file mode 100644 (file)
index 0000000..c319c61
--- /dev/null
@@ -0,0 +1,34 @@
+constructionModelesLassoRank = function(Pi,Rho,mini,maxi,X,Y,tau,A1,rangmin,rangmax){
+  #get matrix sizes
+  n = dim(X)[1]
+  p = dim(X)[2]
+  m = dim(rho)[2]
+  k = dim(rho)[3]
+  L = dim(A1)[2]
+  
+  deltaRank = rangmax - rangmin + 1
+  Size = deltaRank^k
+  Rank = matrix(0, Size, k)
+  for(r in 1:k){
+    Rank[,r] = rangmin + 
+  }
+  
+  phi = array(0, dim=c(p,m,k,L*Size))
+  lvraisemblance = matrix(0, L*Size, 2)
+  for(lambdaIndex in 1:L){
+    #on ne garde que les colonnes actives
+    #active sera l'ensemble des variables informatives
+    active = A1[, lambdaIndex]
+    active[active==0] = c()
+    if(length(active)>0){
+      for(j in 1:Size){
+        EMG_rank = EMGrank(Pi[,lambdaIndex], Rho[,,,lambdaIndex], mini, maxi, X[, active], Y, tau, Rank[j,])
+        phiLambda = EMG_rank$phi
+        LLF = EMG_rank$LLF
+        lvraisemblance[(lambdaIndex-1)*Size+j,] = c(LLF, sum(Rank[j,]^(length(active)- Rank[j,]+m)))
+        phi[active,,,(lambdaIndex-1)*Size+j] = phiLambda
+      }
+    }
+  }
+  return(list(phi=phi, lvraisemblance = lvraisemblance))
+}
\ No newline at end of file