debug test.EMGLLF
[valse.git] / R / basicInitParameters.R
1 #-----------------------------------------------------------------------
2 #' Initialize the parameters in a basic way (zero for the conditional mean,
3 #' uniform for weights, identity for covariance matrices, and uniformly distributed forthe clustering)
4 #' @param n sample size
5 #' @param p number of covariates
6 #' @param m size of the response
7 #' @param k number of clusters
8 #' @return list with phiInit, rhoInit,piInit,gamInit
9 #' @export
10 #-----------------------------------------------------------------------
11 basic_Init_Parameters = function(n,p,m,k)
12 {
13 phiInit = array(0, dim=c(p,m,k))
14
15 piInit = (1./k)*rep.int(1,k)
16
17 rhoInit = array(0, dim=c(m,m,k))
18 for(i in 1:k)
19 rhoInit[,,i] = diag(m)
20
21 gamInit = 0.1*array(1, dim=c(n,k))
22 R = sample(1:k,n, replace=TRUE)
23 for(i in 1:n)
24 gamInit[i,R[i]] = 0.9
25 gamInit = gamInit/sum(gamInit[1,])
26
27 return (data = list(phiInit = phiInit, rhoInit = rhoInit, piInit = piInit, gamInit = gamInit))
28 }