The function produces some convergence plots from the Monte Carlo draws.
convergence.plot(
model,
file = "convergence-output.pdf",
plotfun = "all",
pars = NULL,
point_est = "median",
prob = 0.5,
prob_outer = 0.9,
lags = 10,
warmup = F,
width = 7,
height = 7
)
A .pdf file with one plot per page.
an object of class `flexreg`
.
a character string giving the name of the file (including the extension .pdf) containing the convergence plots. If NULL
, the convergence plots are printed in the graphics window.
an optional character vector of diagnostics plots. The default is to compute "all"
plots, otherwise one can specify a subset of plots among "density"
, "trace"
, "intervals"
, "rate"
, "rhat"
, and "acf"
.
an optional character vector of parameter names. If pars
is not specified, all parameters in the regression models are evaluated.
an optional character to specify the point estimate to be shown between "median"
(the default), "mean"
, or "none"
.
the probability mass to be included in the inner interval (for "intervals"
plot) or in the shaded region (for "density"
plot). The default is 0.5.
the probability mass to be included in the outer interval of the "intervals"
plot. The default is 0.9.
the number of lags to be shown in the "acf"
plot. The default is 10.
a logical scalar indicating whether to include the warmup draws or not (default).
the width and height of the graphics region of each plot in inches. The default values are 7.
"density"
returns a density plot for each parameter in pars
computed from the posterior draws. See bayesplot::mcmc_areas
for further details.
"trace"
returns a trace plot for each parameter in pars
computed from the posterior draws. See bayesplot::mcmc_trace
for further details.
"intervals"
returns a plot of uncertainty interval for each parameter in pars
computed from the posterior draws. See bayesplot::mcmc_intervals
for further details.
"rate"
returns a plot for each parameter in pars
with the number of iterations on the x-axis and the Monte Carlo mean until iteration i-th on the y-axis.
"rhat"
returns a plot with the Rhat values for each parameter in pars
. See bayesplot::mcmc_rhat
for further details.
"acf"
returns the autocorrelation plots (one for each parameter in pars
). See bayesplot::mcmc_acf
for further details.
Moreover, the convergence plots can be further customized using the ggplot2 package.
Brooks, SP., Gelman, A. (1998). General methods for monitoring convergence of iterative simulations. Journal of Computational and Graphical Statistics, 7, 434-455.
Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.19.3. https://mc-stan.org
if (FALSE) {
data("Reading")
FB <- flexreg(accuracy.adj ~ iq, data = Reading, type = "FB")
convergence.plot(FB, file = "Convergence_plot_Output.pdf", pars = "beta")
}
Run the code above in your browser using DataLab