Learn R Programming

BayesSIM (version 1.0.0)

getFunction: Get nimbleModel and nimbleSampler Object from the Result of compileModelAndMCMC

Description

Return compiled nimble model object and a corresponding MCMC samplers.

Usage

get_model(object)

get_sampler(object)

Value

get_model returns compiled Nimble model object. get_sampler returns compiled Nimble sampler object, directly using in runMCMC function.

Arguments

object

The result of compileModelAndMCMC function.

See Also

nimbleModel, configureMCMC, buildMCMC, compileNimble, runMCMC

Examples

Run this code
# \donttest{
simdata2 <- data.frame(DATA1$X, y = DATA1$y)

# 1. One tool version
fit_one <- BayesSIM(y ~ ., data = simdata2,
                    niter = 5000, nburnin = 1000, nchain = 1)


# 2. Split version
models <- BayesSIM_setup(y ~ ., data = simdata2)
Ccompile <- compileModelAndMCMC(models)
nimSampler <- get_sampler(Ccompile)
initList <- getInit(models)
mcmc.out <- runMCMC(nimSampler, niter = 5000, nburnin = 1000, thin = 1,
                    nchains = 1, setSeed = TRUE, inits = initList,
                    summary = TRUE, samplesAsCodaMCMC = TRUE)

# "fit_split" becomes exactly the same as the class of "fit_one" object and apply generic functions.
fit_split <- as_bsim(models, mcmc.out)

# }

Run the code above in your browser using DataLab