- p = dim(covX)[1]
- m = dim(covY)[1]
- k = dim(covY)[3]
-
- X = matrix(nrow=n,ncol=p)
- Y = matrix(nrow=n,ncol=m)
- class = matrix(nrow = n)
-
- require(MASS) #simulate from a multivariate normal distribution
- for (i in 1:n)
- {
- class[i] = sample(1:k, 1, prob=pi)
- X[i,] = mvrnorm(1, meanX[,class[i]], covX[,,class[i]])
- Y[i,] = mvrnorm(1, X[i,] %*% beta[,,class[i]], covY[,,class[i]])
- }
-
- return (list(X=X,Y=Y, class = class))
+ p = dim(covX)[1]
+ m = dim(covY)[1]
+ k = dim(covY)[3]
+
+ X = matrix(nrow=n,ncol=p)
+ Y = matrix(nrow=n,ncol=m)
+ class = matrix(nrow = n)
+
+ require(MASS) #simulate from a multivariate normal distribution
+ for (i in 1:n)
+ {
+ class[i] = sample(1:k, 1, prob=pi)
+ X[i,] = mvrnorm(1, meanX, covX)
+ print(X[i,])
+ print(beta[,,class[i]])
+ Y[i,] = mvrnorm(1, X[i,] %*% beta[,,class[i]], covY[,,class[i]])
+ }
+
+ return (list(X=X,Y=Y, class = class))