Description Usage Arguments Details Author(s) Examples
Accepts a single required argument, which may be of class MCMCspec, or inherit from class modelBaseClass (a NIMBLE model obejct). Returns an MCMC function; see details section.
1 |
obj |
An object of class MCMCspec, which specifys
the model, samplers, monitors, and thinning intervals for
the resulting MCMC function. See |
Calling buildMCMC(obj) will produce an R mcmc function object, say 'Rmcmc'.
The Rmcmc function will have arguments:
niter: The number of iterations to run the MCMC.
reset: Boolean specifying whether to reset the model and stored samples. This will simulate into any stochastic nodes with value NA, propagate values through any deterministic nodes, and calculate all model probabilities. This will also reset the internal stored MCMC samples. Specifying reset=FALSE allows the MCMC algorithm to continue running from where it left off. Generally, reset=FALSE should only be used when the MCMC has already been run. See examples.
simulateAll: Boolean specifying whether to simulate into all stochastic nodes. This will overwrite the current values in all stochastic nodes.
Samples corresponding to the 'monitors' and 'monitors2' from the MCMCspec are stored into the interval variables 'mvSamples' and 'mvSamples2', respectively. These may be accessed via: Rmcmc$mvSamples Rmcmc$mvSamples2
The Rmcmc function may be compiled to a C MCMC object, taking care to compile in the same project as the R model object, using: Cmcmc <- compileNimble(Rmcmc, project=Rmodel)
The Cmcmc function will function identically to the Rmcmc object, except acting on the C model object.
Daniel Turek
1 2 3 4 5 6 7 8 9 10 11 | code <- nimbleCode({
mu ~ dnorm(0, 1)
x ~ dnorm(mu, 1)
})
Rmodel <- nimbleModel(code)
spec <- configureMCMC(Rmodel)
Rmcmc <- buildMCMC(spec)
Rmcmc$run(10)
samples <- Rmcmc$mvSamples
samples[['x']]
Rmcmc$run(100, reset = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.