Commit | Line | Data |
---|---|---|
39046da6 BA |
1 | generateIO = function(covX, covY, pi, beta, n) |
2 | { | |
3 | size_covX = dim(covX) | |
4 | p = size_covX[1] | |
5 | k = size_covX[3] | |
35b42a4b | 6 | |
39046da6 BA |
7 | size_covY = dim(covY) |
8 | m = size_covY[1] | |
9 | ||
10 | Y = matrix(0,n,m) | |
11 | BX = array(0, dim=c(n,m,k)) | |
12 | ||
13 | require(MASS) #simulate from a multivariate normal distribution | |
14 | for (i in 1:n) | |
15 | { | |
16 | for (r in 1:k) | |
17 | { | |
18 | BXir = rep(0,m) | |
19 | for (mm in 1:m) | |
20 | Bxir[[mm]] = X[i,] %*% beta[,mm,r] | |
21 | Y[i,] = Y[i,] + pi[r] * mvrnorm(1,BXir, covY[,,r]) | |
22 | } | |
23 | } | |
24 | ||
25 | return (list(X=X,Y=Y)) | |
26 | } |