plot-methods | R Documentation |
The default plot shows posterior uncertainty intervals and point
estimates for parameters and generated quantities. The plot
method can
also be used to call the other rstan plotting functions via the
plotfun
argument (see Examples).
## S4 method for signature 'stanfit,missing'
plot(x, ..., plotfun)
x |
An instance of class |
plotfun |
A character string naming the plotting function to apply to the
stanfit object. If |
... |
Optional arguments to |
A ggplot
object that can be further customized
using the ggplot2 package.
Because the rstan plotting functions use ggplot2 (and thus the
resulting plots behave like ggplot
objects), when calling a plotting
function within a loop or when assigning a plot to a name
(e.g., graph <- plot(fit, plotfun = "rhat")
),
if you also want the side effect of the plot being displayed you
must explicity print it (e.g., (graph <- plot(fit, plotfun = "rhat"))
,
print(graph <- plot(fit, plotfun = "rhat"))
).
List of RStan plotting functions
,
Plot options
## Not run:
library(rstan)
fit <- stan_demo("eight_schools")
plot(fit)
plot(fit, show_density = TRUE, ci_level = 0.5, fill_color = "purple")
plot(fit, plotfun = "hist", pars = "theta", include = FALSE)
plot(fit, plotfun = "trace", pars = c("mu", "tau"), inc_warmup = TRUE)
plot(fit, plotfun = "rhat") + ggtitle("Example of adding title to plot")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.