#' Generate a sample of (X,Y) of size n
-#' @param meanX matrix of group means for covariates (of size p)
-#' @param covX covariance for covariates (of size p*p)
-#' @param covY covariance for the response vector (of size m*m*K)
-#' @param pi proportion for each cluster
+#' @param meanX matrix of group means for covariates (p x K)
+#' @param covX covariance for covariates (p x p x K)
+#' @param covY covariance for the response vector (m x m x K)
+#' @param pi proportion for each cluster
#' @param beta regression matrix, of size p*m*k
-#' @param n sample size
+#' @param n sample size
#'
#' @return list with X and Y
#' @export
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]])
+ X[i,] = mvrnorm(1, meanX[,class[i]], covX[,,class[i]])
Y[i,] = mvrnorm(1, X[i,] %*% beta[,,class[i]], covY[,,class[i]])
}
k = 2
D = 20
-meanX = rep(0,p)
-covX = 0.1*diag(p)
+meanX = matrix(nrow=p,ncol=k)
+meanX[,1] = rep(0,p)
+meanX[,2] = rep(1,p)
+
+covX = array(dim=c(p,p,k))
+covX[,,1] = 0.1*diag(p)
+covX[,,2] = 0.5*diag(p)
covY = array(dim = c(q,q,k))
covY[,,1] = 0.1*diag(q)
sumLLF1 = 0.0;
for (r in 1:k)
{
- Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r])* det(rho[,,r])
+ Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r]) #* det(rho[,,r]) #FIXME: still issues here ?!?!
sumLLF1 = sumLLF1 + Gam[i,r] / (2*base::pi)^(m/2)
}
sumLogLLF2 = sumLogLLF2 + log(sumLLF1)