| plot_pars | R Documentation | 
Plot many types of plots of parameter estimates. See examples for typical use cases.
plot_pars(
  fit,
  pars = "population",
  regex_pars = character(0),
  type = "combo",
  ncol = 1,
  prior = FALSE
)
| fit | An  | 
| pars | Character vector. One of: 
 | 
| regex_pars | Vector of regular expressions. This will typically just be the beginning of the parameter name(s), i.e., "^cp_" plots all change points, "^my_varying" plots all levels of a particular varying effect, and "^cp_|^my_varying" plots both. | 
| type | String or vector of strings. Calls  | 
| ncol | Number of columns in plot. This is useful when you have many
parameters and only one plot  | 
| prior | TRUE/FALSE. Plot using prior samples? Useful for  | 
For other type, it calls bayesplot::mcmc_type(). Use these
directly on fit$mcmc_post or fit$mcmc_prior if you want finer
control of plotting, e.g., bayesplot::mcmc_dens(fit$mcmc_post). There
are also a number of useful plots in the coda package, i.e.,
coda::gelman.plot(fit$mcmc_post) and coda::crosscorr.plot(fit$mcmc_post)
In any case, if you see a few erratic lines or parameter estimates, this is
a sign that you may want to increase argument 'adapt' and 'iter' in mcp.
A ggplot2 object.
Jonas Kristoffer Lindeløv jonas@lindeloev.dk
# Typical usage. demo_fit is an mcpfit object.
plot_pars(demo_fit)
## Not run: 
# More options
plot_pars(demo_fit, regex_pars = "^cp_")  # Plot only change points
plot_pars(demo_fit, pars = c("int_3", "time_3"))  # Plot these parameters
plot_pars(demo_fit, type = c("trace", "violin"))  # Combine plots
# Some plots only take pairs. hex is good to assess identifiability
plot_pars(demo_fit, type = "hex", pars = c("cp_1", "time_2"))
# Visualize the priors:
plot_pars(demo_fit, prior = TRUE)
# Useful for varying effects:
# plot_pars(my_fit, pars = "varying", ncol = 3)  # plot all varying effects
# plot_pars(my_fit, regex_pars = "my_varying", ncol = 3)  # plot all levels of a particular varying
# Customize multi-column ggplots using "*" instead of "+" (patchwork)
library(ggplot2)
plot_pars(demo_fit, type = c("trace", "dens_overlay")) * theme_bw(10)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.