X-Git-Url: https://git.auder.net/?p=morpheus.git;a=blobdiff_plain;f=pkg%2FR%2FsampleIO.R;h=9419c32c12c7cca866251a0e2c8129677d230924;hp=10497dbb487801f7f2d372a530b86217bfa493a7;hb=ab35f6102896a49e86e853262c0650faa2931638;hpb=0f5fbd1371011f25cd1f6caf0e826d2ea9e4e245 diff --git a/pkg/R/sampleIO.R b/pkg/R/sampleIO.R index 10497db..9419c32 100644 --- a/pkg/R/sampleIO.R +++ b/pkg/R/sampleIO.R @@ -4,6 +4,8 @@ #' 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 @@ -17,11 +19,17 @@ #' \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)