Skip to content

Commit

Permalink
Pass mcmc_chains
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Aug 3, 2023
1 parent 89ed12b commit 082deba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/sample-re-mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @param model Which delta/hurdle model component?
#' @param mcmc_iter Iterations for MCMC residuals. Will take the last one.
#' @param mcmc_warmup Warmup for MCMC residuals.
#' @param mcmc_chains MCMC chains.
#' @param print_stan_model Print the Stan model from MCMC residuals?
#' @param stan_args A list of arguments that will be passed to [rstan::sampling()].
#' @param nsim Number of MCMC samples to return.
Expand Down Expand Up @@ -82,6 +83,7 @@ sample_mle_mcmc <- function(
object,
mcmc_warmup = 250,
mcmc_iter = 500,
mcmc_chains = 1,
stan_args = NULL) {
obj <- object$tmb_obj
random <- unique(names(obj$env$par[obj$env$random]))
Expand All @@ -105,7 +107,7 @@ sample_mle_mcmc <- function(
obj <- TMB::MakeADFun(obj$env$data, pl, map = map, DLL = "sdmTMB")

# run MCMC to get posterior sample of random effects given data:
args <- list(obj = obj, chains = 1L, iter = mcmc_iter, warmup = mcmc_warmup)
args <- list(obj = obj, chains = mcmc_chains, iter = mcmc_iter, warmup = mcmc_warmup)
args <- c(args, stan_args)
do.call(tmbstan::tmbstan, args)
}
10 changes: 9 additions & 1 deletion man/predict_mle_mcmc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 082deba

Please sign in to comment.