View source: R/bayes-methods.R
| plot.dsge_bayes | R Documentation |
Produces diagnostic plots for posterior draws from a Bayesian DSGE fit.
## S3 method for class 'dsge_bayes'
plot(
x,
type = c("trace", "density", "prior_posterior", "running_mean", "acf", "pairs", "all",
"irf"),
pars = NULL,
...
)
x |
A |
type |
Character. Plot type:
|
pars |
Character vector of parameter names to include. If |
... |
Additional arguments. For |
All plot types except pairs and irf handle any number of parameters
by paginating across multiple plot pages (up to 4 parameters per page).
In interactive sessions, devAskNewPage() is used to prompt between pages.
For the "pairs" plot, at most 1000 draws are used to keep the plot
readable. The correlation matrix is printed to the console.
Forecast plotting is not currently supported for Bayesian fits.
Use irf() for posterior impulse-response analysis.
Invisibly returns the dsge_bayes object x. Called for the
side effect of producing diagnostic plots on the active graphics device.
m <- dsge_model(
obs(y ~ z),
state(z ~ rho * z),
start = list(rho = 0.5)
)
set.seed(42)
z <- numeric(200); for (i in 2:200) z[i] <- 0.8 * z[i-1] + rnorm(1)
fit <- bayes_dsge(m, data = data.frame(y = z),
priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)),
chains = 2, iter = 2000, seed = 1)
plot(fit, type = "trace")
plot(fit, type = "density")
plot(fit, type = "prior_posterior")
plot(fit, type = "running_mean")
plot(fit, type = "acf")
plot(fit, type = "all")
# Parameter selection
plot(fit, type = "trace", pars = "rho")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.