1 constructionModelesLassoMLE = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,seuil,tau,A1,A2){
10 phi = array(0, dim=c(p,m,k,L))
11 rho = array(0, dim=c(m,m,k,L))
13 llh = matrix(0, L, 2) #log-likelihood
15 for(lambdaIndex in 1:L){
16 a = A1[, 1, lambdaIndex]
21 EMGLLf = EMGLLF(phiInit[a,,],rhoInit,piInit,gamInit,mini,maxi,gamma,0,X[,a],Y,tau)
23 phiLambda = EMGLLf$phi
24 rhoLambda = EMGLLf$rho
27 for(j in 1:length(a)){
28 phi[a[j],,,lambdaIndex] = phiLambda[j,,]
30 rho[,,,lambdaIndex] = rhoLambda
31 Pi[,lambdaIndex] = piLambda
35 vec = c(2, dim(A2)[2])
36 b = A2[j,vec,lambdaIndex]
39 phi[A2[j,1,lambdaIndex],b,,lambdaIndex] = 0
41 c = A1[j,vec,lambdaIndex]
43 dimension = dimension + length(c)
46 #on veut calculer l'EMV avec toutes nos estimations
47 densite = matrix(0, n, L)
50 delta = Y[i,]%*%rho[,,r,lambdaIndex] - (X[i,a]%*%phi[a,,r,lambdaIndex]);
51 densite[i,lambdaIndex] = densite[i,lambdaIndex] + Pi[r,lambdaIndex]*det(rho[,,r,lambdaIndex])/(sqrt(2*pi))^m*exp(-tcrossprod(delta)/2.0)
54 llh[lambdaIndex,1] = sum(log(densite[,lambdaIndex]))
55 llh[lambdaIndex,2] = (dimension+m+1)*k-1
57 return(list(phi=phi, rho=rho, Pi=Pi, llh = llh))