From 3f145e9ad99f7e4b264215e3e5b648922f67f7b6 Mon Sep 17 00:00:00 2001
From: Benjamin Goehry <benjamin.goehry@math.u-psud.fr>
Date: Tue, 17 Jan 2017 09:37:32 +0100
Subject: [PATCH] construction lasso rank

---
 .../helpers/constructionModelesLassoRank.R    | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 src/test/generate_test_data/helpers/constructionModelesLassoRank.R

diff --git a/src/test/generate_test_data/helpers/constructionModelesLassoRank.R b/src/test/generate_test_data/helpers/constructionModelesLassoRank.R
new file mode 100644
index 0000000..c319c61
--- /dev/null
+++ b/src/test/generate_test_data/helpers/constructionModelesLassoRank.R
@@ -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
-- 
2.44.0