Learn R Programming

ivd (version 1.0.0)

run_MCMC_compiled_model: Run MCMC on an already compiled model Exposed but internal function for future()

Description

Run MCMC on an already compiled model Exposed but internal function for future()

Usage

run_MCMC_compiled_model(
  compiled,
  seed,
  new_data,
  new_inits,
  niter,
  nburnin,
  useWAIC = TRUE,
  ...
)

Value

The output produced by nimble::runMCMC() when applied to a compiled NIMBLE MCMC object. The returned value depends on the useWAIC

argument:

  • If useWAIC = TRUE, a named list containing:

    • samples: A matrix of posterior draws (iterations × parameters).

    • WAIC: The WAIC value computed by NIMBLE.

    • ...: Additional elements returned by runMCMC() when WAIC is enabled.

  • If useWAIC = FALSE, a numeric matrix containing the posterior samples (iterations × parameters) with no additional elements.

This function is intended for internal use (e.g., within future

workers) and is not meant to be called directly by end users.

Arguments

compiled

Compiled nimble model

seed

Seed, set by future

new_data

Data

new_inits

inits

niter

Sampling iteratons

nburnin

Number of burnin iterations

useWAIC

Defaults to TRUE

...

Placeholder for nimble arguments

Examples

Run this code
if (FALSE) {
library(nimble)
# Generic nimble example
code <- nimbleCode({
  mu ~ dnorm(0, 1)
  x  ~ dnorm(mu, 1)
})

constants   <- list()
dummy_data  <- list(x = 0)
dummy_inits <- list(mu = 0)

out <- build_ivd_model(
  code        = code,
  constants   = constants,
  dummy_data  = dummy_data,
  dummy_inits = dummy_inits,
  useWAIC     = FALSE
)

str(out)
}

Run the code above in your browser using DataLab