#' into K groups of proportions p. Inside one group, the probability law P(Y=1) is
#' described by the corresponding column parameter in the matrix β + intercept b.
#'
+#' @name generateSampleIO
+#'
#' @param n Number of individuals
#' @param p Vector of K(-1) populations relative proportions (sum (<)= 1)
#' @param β Vectors of model parameters for each population, of size dxK
#' \item{index: the population index (in 1:K) for each row in X}
#' }
#'
+#' @examples
+#' # K = 3 so we give first two components of p: 0.3 and 0.3 (p[3] = 0.4)
+#' io <- generateSampleIO(1000, c(.3,.3),
+#' matrix(c(1,3,-1,1,2,1),ncol=3), c(.5,-1,0), "logit")
+#' io$index[1] #number of the group of X[1,] and Y[1] (in 1...K)
+#'
#' @export
-generateSampleIO = function(n, p, β, b, link)
+generateSampleIO <- function(n, p, β, b, link)
{
# Check arguments
- tryCatch({n = as.integer(n)}, error=function(e) stop("Cannot convert n to integer"))
+ tryCatch({n <- as.integer(n)}, error=function(e) stop("Cannot convert n to integer"))
if (length(n) > 1)
warning("n is a vector but should be scalar: only first element used")
if (n <= 0)