
stan_plot(object, pars, include = TRUE, unconstrain = FALSE,
...)
stan_trace(object, pars, include = TRUE, unconstrain = FALSE,
inc_warmup = FALSE, nrow = NULL, ncol = NULL,
...)
stan_scat(object, pars, include = TRUE, unconstrain = FALSE,
inc_warmup = FALSE, nrow = NULL, ncol = NULL,
...)
stan_hist(object, pars, include = TRUE, unconstrain = FALSE,
inc_warmup = FALSE, nrow = NULL, ncol = NULL,
...) stan_dens(object, pars, include = TRUE, unconstrain = FALSE,
inc_warmup = FALSE, nrow = NULL, ncol = NULL,
..., separate_chains = FALSE)
stan_ac(object, pars, include = TRUE, unconstrain = FALSE,
inc_warmup = FALSE, nrow = NULL, ncol = NULL,
..., separate_chains = FALSE, lags = 25, partial = FALSE)
quietgg(gg)
object
is a stanfit object, the default is to show
all user-defined parameters or the first 10 (if there are more
than 10). If object
is a stanreg object, the defaultpars
argument be
included (the default) or excluded from the plot?FALSE
. Only available if object
is a
stanfit object.FALSE
.facet_wrap
.stan_trace
the geom is geom_path
and we could specify
linetype
, size
, alpha
, etc.). For s
stan_dens
, should the density for each
chain be plotted? The default is FALSE
, which means that for each
parameter the draws from all chains are combined. For stan_ac
,
if separate_chains=FALSE
stan_ac
, the maximum number of lags to show.stan_ac
, should partial autocorrelations be
plotted instead? Defaults to FALSE
.ggplot
object that can be further customized
using the stan_plot
, there are additional arguments
(listed below with their default values) that can be specified in ...
.[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
List of RStan plotting functions
,
Plot options
example("read_stan_csv")
stan_plot(fit)
stan_trace(fit)
library(gridExtra)
fit <- stan_demo("eight_schools")
stan_plot(fit)
stan_plot(fit, show_density = TRUE, fill_color = "maroon")
# histograms
stan_hist(fit)
# suppress ggplot2 messages about default bindwidth
quietgg(stan_hist(fit))
quietgg(h <- stan_hist(fit, pars = "theta", binwidth = 5))
# juxtapose histograms of tau and unconstrained tau
tau <- stan_hist(fit, pars = "tau")
tau_unc <- stan_hist(fit, pars = "tau", unconstrain = TRUE) +
xlab("tau unconstrained")
grid.arrange(tau, tau_unc)
# kernel density estimates
stan_dens(fit)
(dens <- stan_dens(fit, fill = "skyblue", ))
dens <- dens + ggtitle("Kernel Density Estimates\n") + xlab("")
dens
(dens_sep <- stan_dens(fit, separate_chains = TRUE, alpha = 0.3))
dens_sep + scale_fill_manual(values = c("red", "blue", "green", "black"))
(dens_sep_stack <- stan_dens(fit, pars = "theta", alpha = 0.5,
separate_chains = TRUE, position = "stack"))
# traceplot
trace <- stan_trace(fit)
window <- coord_cartesian(xlim = c(1500,1600))
quietgg(trace + window)
trace +
scale_color_manual(values = c("red", "blue", "green", "black"))
trace +
scale_color_brewer(type = "div") +
theme(legend.position = "none")
facet_style <- theme(strip.background = element_rect(fill = "white"),
strip.text = element_text(size = 13, color = "black"))
(trace <- trace + facet_style)
# scatterplot
(mu_vs_tau <- stan_scat(fit, pars = c("mu", "tau"), color = "blue", size = 4))
mu_vs_tau +
coord_flip() +
theme(panel.background = element_rect(fill = "black"))
Run the code above in your browser using DataLab