- dimension = dimension + sum(sel.lambda[,j]!=0)
- }
-
- #on veut calculer la vraisemblance avec toutes nos estimations
- densite = vector("double",n)
- for (r in 1:k)
- {
- delta = Y%*%rhoLambda[,,r] - (X[, col.sel]%*%phiLambda[col.sel,,r])
- densite = densite + piLambda[r] *
- det(rhoLambda[,,r])/(sqrt(2*base::pi))^m * exp(-tcrossprod(delta)/2.0)
+
+ dimension = 0
+ for (j in 1:p){
+ b = setdiff(1:m, sel.lambda[,j])
+ if (length(b) > 0){
+ phiLambda[j,b,] = 0.0
+ }
+ dimension = dimension + sum(sel.lambda[,j]!=0)
+ }
+
+ #on veut calculer la vraisemblance avec toutes nos estimations
+ densite = vector("double",n)
+ for (r in 1:k)
+ {
+ delta = Y%*%rhoLambda[,,r] - (X[, col.sel]%*%phiLambda[col.sel,,r])
+ densite = densite + piLambda[r] *
+ det(rhoLambda[,,r])/(sqrt(2*base::pi))^m * exp(-tcrossprod(delta)/2.0)
+ }
+ llhLambda = c( sum(log(densite)), (dimension+m+1)*k-1 )
+ list("phi"= phiLambda, "rho"= rhoLambda, "pi"= piLambda, "llh" = llhLambda)