revert src/test/utils.c
[valse.git] / R / generateIOdefault.R
1 #' Generate a sample of (X,Y) of size n with default values
2 #' @param n sample size
3 #' @param p number of covariates
4 #' @param m size of the response
5 #' @param k number of clusters
6 #' @return list with X and Y
7 #' @export
8 #-----------------------------------------------------------------------
9 generateIOdefault = function(n, p, m, k)
10 {
11 covX = diag(p)
12 covY = array(0, dim=c(m,m,k))
13 for(r in 1:k)
14 {
15 covY[,,r] = diag(m)
16 }
17
18 pi = rep(1./k,k)
19
20 beta = array(0, dim=c(p,m,k))
21 for(j in 1:p)
22 {
23 nonZeroCount = ceiling(m * runif(1))
24 beta[j,1:nonZeroCount,] = matrix(runif(nonZeroCount*k), ncol=k)
25 }
26
27 sample_IO = generateIO(covX, covY, pi, beta, n)
28 return (list(X=sample_IO$X,Y=sample_IO$Y))
29 }