1 #' Generate a sample of (X,Y) of size n
2 #' @param covX covariance for covariates (of size p*p*K)
3 #' @param covY covariance for the response vector (of size m*m*K)
4 #' @param pi proportion for each cluster
5 #' @param beta regression matrix
6 #' @param n sample size
8 #' @return list with X and Y
10 #-----------------------------------------------------------------------
11 generateIO = function(covX, covY, pi, beta, n)
19 BX = array(0, dim=c(n,m,k))
21 require(MASS) #simulate from a multivariate normal distribution
28 Bxir[[mm]] = X[i,] %*% beta[,mm,r]
29 Y[i,] = Y[i,] + pi[r] * mvrnorm(1,BXir, covY[,,r])
33 return (list(X=X,Y=Y))