utilisation de k-means au lieu de hierarchique dans initSmallEM - PB de dimensions...
[valse.git] / R / discardSimilarModels.R
1 #' Discard models which have the same relevant variables
2 #'
3 #' @param B1 array of relevant coefficients (of size p*m*length(gridlambda))
4 #' @param B2 array of irrelevant coefficients (of size p*m*length(gridlambda))
5 #' @param glambda grid of regularization parameters (vector)
6 #' @param rho covariance matrix (of size m*m*K*size(gridLambda))
7 #' @param pi weight parameters (of size K*size(gridLambda))
8 #'
9 #' @return a list with update B1, B2, glambda, rho and pi, and ind the vector of indices
10 #' of selected models.
11 #' @export
12 discardSimilarModels = function(B1,B2,glambda,rho,pi)
13 {
14 ind = c()
15 for (j in 1:length(glambda))
16 {
17 for (ll in 1:(l-1))
18 {
19 if(B1[,,l] == B1[,,ll])
20 ind = c(ind, l)
21 }
22 }
23 ind = unique(ind)
24 B1 = B1[,,-ind]
25 glambda = glambda[-ind]
26 B2 = B2[,,-ind]
27 rho = rho[,,,-ind]
28 pi = pi[,-ind]
29
30 return (list(B1=B1,B2=B2,glambda=glambda,rho=rho,pi=pi,ind=ind))
31 }