as_draws_df.mcmc_output | R Documentation |
run_mcmc
Output to draws_df
FormatConverts MCMC output from run_mcmc
call to a
draws_df
format of the posterior
package. This enables the use
of diagnostics and plotting methods of posterior
and bayesplot
packages.
## S3 method for class 'mcmc_output' as_draws_df(x, times, states, ...) ## S3 method for class 'mcmc_output' as_draws(x, times, states, ...)
x |
An object of class |
times |
A vector of indices defining which time points to return? Default is all. |
states |
A vector of indices defining which states to return. Default is all. |
... |
Ignored. |
A draws_df
object.
The jump chain representation is automatically expanded by
as_draws
, but if run_mcmc
used IS-MCMC method, the output
contains additional weight
column corresponding to the IS-weights
(without counts), which is ignored by posterior
and bayesplot
,
i.e. those results correspond to approximate MCMC.
model <- bsm_lg(Nile, sd_y = tnormal(init = 100, mean = 100, sd = 100, min = 0), sd_level = tnormal(init = 50, mean = 50, sd = 100, min = 0), a1 = 1000, P1 = 500^2) fit1 <- run_mcmc(model, iter = 2000) draws <- as_draws(fit1) head(draws, 4) estimate_ess(draws$sd_y) summary(fit1, return_se = TRUE) # More chains: model$theta[] <- c(50, 150) # change initial value fit2 <- run_mcmc(model, iter = 2000, verbose = FALSE) model$theta[] <- c(150, 50) # change initial value fit3 <- run_mcmc(model, iter = 2000, verbose = FALSE) # it is actually enough to transform first mcmc_output to draws object, # rest are transformed automatically inside bind_draws draws <- posterior::bind_draws(as_draws(fit1), as_draws(fit2), as_draws(fit3), along = "chain") posterior::rhat(draws$sd_y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.