1 #' Generate a sample of (X,Y) of size n with default values
3 #' @param n sample size
4 #' @param p number of covariates
5 #' @param m size of the response
6 #' @param k number of clusters
8 #' @return list with X and Y
10 generateXYdefault = function(n, p, m, k)
14 covY = array(dim=c(m,m,k))
18 #initialize beta to a random number of non-zero random value
19 β = array(0, dim=c(p,m,k))
22 nonZeroCount = sample(1:m, 1)
23 β[j,1:nonZeroCount,] = matrix(runif(nonZeroCount*k), ncol=k)
26 sample_IO = generateXY(n, π, meanX, β, covX, covY)
27 return (list(X=sample_IO$X,Y=sample_IO$Y))
30 #' Initialize the parameters in a basic way (zero for the conditional mean, uniform for
31 #' weights, identity for covariance matrices, and uniformly distributed for the
34 #' @param n sample size
35 #' @param p number of covariates
36 #' @param m size of the response
37 #' @param k number of clusters
39 #' @return list with phiInit, rhoInit,piInit,gamInit
41 basicInitParameters = function(n,p,m,k)
43 phiInit = array(0, dim=c(p,m,k))
45 piInit = (1./k)*rep(1,k)
47 rhoInit = array(dim=c(m,m,k))
49 rhoInit[,,i] = diag(m)
51 gamInit = 0.1 * matrix(1, nrow=n, ncol=k)
52 R = sample(1:k, n, replace=TRUE)
55 gamInit = gamInit/sum(gamInit[1,])
57 return (list("phiInit"=phiInit, "rhoInit"=rhoInit, "piInit"=piInit, "gamInit"=gamInit))