Commit | Line | Data |
---|---|---|
35b42a4b B |
1 | library(MASS) #generalized inverse of matrix Monroe-Penrose |
2 | ||
3 | vec_bin = function(X,r){ | |
4 | Z = c() | |
5 | indice = c() | |
6 | j=1 | |
7 | for(i in 1:length(X)){ | |
8 | if(X[i] == r){ | |
9 | Z[i] = 1 | |
10 | indice[j] = i | |
11 | j=j+1 | |
12 | } | |
13 | else{ | |
14 | Z[i] = 0 | |
15 | } | |
16 | } | |
17 | return(list(Z,indice)) | |
18 | } | |
19 | ||
20 | initSmallEM = function(k,X,Y,tau){ | |
21 | n = nrow(Y) | |
22 | m = ncol(Y) | |
23 | p = ncol(X) | |
24 | ||
25 | betaInit1 = array(0, dim=c(p,m,k,20)) | |
26 | sigmaInit1 = array(0, dim = c(m,m,k,20)) | |
27 | phiInit1 = array(0, dim = c(p,m,k,20)) | |
28 | rhoInit1 = array(0, dim = c(m,m,k,20)) | |
29 | piInit1 = matrix(0,20,k) | |
30 | gamInit1 = array(0, dim=c(n,k,20)) | |
31 | LLFinit1 = list() | |
32 | ||
33 | ||
34 | for(repet in 1:20){ | |
35 | clusters = hclust(dist(y)) #default distance : euclidean | |
36 | clusterCut = cutree(clusters,k) | |
37 |