From: Benjamin Auder Date: Tue, 27 Feb 2018 14:33:36 +0000 (+0100) Subject: Get index information into prepareArgs for multirun() X-Git-Url: https://git.auder.net/variants/current/doc/scripts/css/img/cross.svg?a=commitdiff_plain;h=5fc1b9d9bbb20ebf5228792f5885b77991c0cec9;p=morpheus.git Get index information into prepareArgs for multirun() --- diff --git a/pkg/R/multiRun.R b/pkg/R/multiRun.R index 0a5c843..0a2a833 100644 --- a/pkg/R/multiRun.R +++ b/pkg/R/multiRun.R @@ -39,8 +39,11 @@ #' model=FLXMRglm(family="binomial") ) ) #' normalize( matrix(out@@coef[1:(ncol(fargs$X)*K)], ncol=K) ) #' } ), -#' prepareArgs = function(fargs) { -#' fargs$ind <- sample(1:nrow(fargs$X),replace=TRUE) +#' prepareArgs = function(fargs,index) { +#' if (index == 1) +#' fargs$ind <- 1:nrow(fargs$X) +#' else +#' fargs$ind <- sample(1:nrow(fargs$X),replace=TRUE) #' fargs #' }, N=10, ncores=3) #' for (i in 1:2) @@ -65,7 +68,7 @@ #' model=FLXMRglm(family="binomial") ) ) #' sapply( seq_len(K), function(i) as.double( out@@components[[1]][[i]][,1] ) ) #' } ), -#' prepareArgs = function(fargs) { +#' prepareArgs = function(fargs,index) { #' library(morpheus) #' io = generateSampleIO(fargs$n, fargs$p, fargs$β, fargs$b, fargs$optargs$link) #' fargs$X = io$X @@ -78,7 +81,7 @@ #' res[[i]] <- alignMatrices(res[[i]], ref=β, ls_mode="exact")} #' @export multiRun <- function(fargs, estimParams, - prepareArgs = function(x) x, N=10, ncores=3, agg=lapply, verbose=FALSE) + prepareArgs = function(x,i) x, N=10, ncores=3, agg=lapply, verbose=FALSE) { if (!is.list(fargs)) stop("fargs: list") @@ -95,7 +98,7 @@ multiRun <- function(fargs, estimParams, estimParamAtIndex <- function(index) { - fargs <- prepareArgs(fargs) + fargs <- prepareArgs(fargs, index) if (verbose) cat("Run ",index,"\n") lapply(seq_along(estimParams), function(i) { diff --git a/pkg/R/plot.R b/pkg/R/plot.R index f94f19a..0097607 100644 --- a/pkg/R/plot.R +++ b/pkg/R/plot.R @@ -18,7 +18,7 @@ extractParam <- function(mr, x=1, y=1) #' #' @param mr Output of multiRun(), list of lists of functions results #' @param x Row index of the element inside the aggregated parameter -#' @param y Colomn index of the element inside the aggregated parameter +#' @param y Column index of the element inside the aggregated parameter #' #' @examples #' \dontrun{