1 library(MASS) #simulate from a multivariate normal distribution
3 generateIO = function(meanX, covX, covY, pi, beta, n){ #don't need meanX
12 BX = array(0, dim=c(n,m,k))
18 Bxir[[mm]] = X[i,] %*% beta[,mm,r]
20 Y[i,]=Y[i,] + pi[[r]] * mvrnorm(1,BXir, covY[,,r])