1 constructionModelesLassoMLE = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,
11 phi = array(0, dim=c(p,m,k,L))
12 rho = array(0, dim=c(m,m,k,L))
14 llh = matrix(0, L, 2) #log-likelihood
16 for(lambdaIndex in 1:L)
18 a = A1[,1,lambdaIndex]
23 res = EMGLLF(phiInit[a,,],rhoInit,piInit,gamInit,mini,maxi,gamma,0.,X[,a],Y,tau)
25 #TODO: supprimer ça et utiliser parLapply(...)
26 for (j in 1:length(a))
27 phi[a[j],,,lambdaIndex] = res$phi[j,,]
28 rho[,,,lambdaIndex] = res$rho
29 pi[,lambdaIndex] = res$pi
32 for (j in 1:p) #TODO: doit pouvoir être fait beaucoup plus simplement
34 b = A2[j,2:dim(A2)[2],lambdaIndex]
37 phi[A2[j,1,lambdaIndex],b,,lambdaIndex] = 0.
38 c = A1[j,2:dim(A1)[2],lambdaIndex]
39 dimension = dimension + sum(c!=0)
42 #on veut calculer l'EMV avec toutes nos estimations
43 densite = matrix(0, nrow=n, ncol=L)
44 for (i in 1:n) #TODO: pas besoin de cette boucle (vectorize)
48 delta = Y[i,]%*%rho[,,r,lambdaIndex] - (X[i,a]%*%phi[a,,r,lambdaIndex]);
49 densite[i,lambdaIndex] = densite[i,lambdaIndex] + pi[r,lambdaIndex] *
50 det(rho[,,r,lambdaIndex])/(sqrt(2*base::pi))^m * exp(-tcrossprod(delta)/2.0)
53 llh[lambdaIndex,1] = sum(log(densite[,lambdaIndex]))
54 llh[lambdaIndex,2] = (dimension+m+1)*k-1
56 return (list("phi"=phi, "rho"=rho, "pi"=pi, "llh" = llh))