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)
Run the code above in your browser using DataLab