plot.stapreg.Rd
The plot
method for stapreg-objects provides a convenient
interface to the MCMC module in the bayesplot
package for plotting MCMC draws and diagnostics. It is also straightforward
to use the functions from the bayesplot package directly rather than
via the plot
method. Examples of both methods of plotting are given
below.
# S3 method for stapreg plot(x, plotfun = "intervals", pars = NULL, regex_pars = NULL, ...)
x | A fitted model object returned by one of the
rstap modeling functions. See |
---|---|
plotfun | A character string naming the bayesplot
MCMC function to use. The default is to call
|
pars | An optional character vector of parameter names. |
regex_pars | An optional character vector of regular
expressions to use for parameter selection. |
... | Additional arguments to pass to |
Either a ggplot object that can be further customized using the
ggplot2 package, or an object created from multiple ggplot objects
(e.g. a gtable object created by arrangeGrob
).
Gabry, J., Simpson, D., Vehtari, A., Betancourt, M., and Gelman, A. (2018). Visualization in Bayesian workflow. Journal of the Royal Statistical Society Series A, accepted for publication. arXiv preprint: http://arxiv.org/abs/1709.01449.
The vignettes in the bayesplot package for many examples.
MCMC-overview
(bayesplot) for links to
the documentation for all the available plotting functions.
color_scheme_set
(bayesplot) to change
the color scheme used for plotting.
pp_check
for graphical posterior predictive checks.
if (FALSE) { # Not run for CRAN check speed fit_glm <- stap_glm(formula = y ~ sex + sap(Fast_Food), subject_data = homog_subject_data, distance_data = homog_distance_data, family = gaussian(link = 'identity'), subject_ID = 'subj_id', prior = normal(location = 0, scale = 5, autoscale = F), prior_intercept = normal(location = 25, scale = 5, autoscale = F), prior_stap = normal(location = 0, scale = 3, autoscale = F), prior_theta = log_normal(location = 1, scale = 1), prior_aux = cauchy(location = 0,scale = 5), max_distance = max(homog_distance_data$Distance), chains = CHAINS, iter = ITER, refresh = -1,verbose = F) plot(fit_glm, plotfun = 'mcmc_hist', pars = "Fast_Food") }