Learn R Programming

rstan (version 2.9.0-3)

plot-methods: Plots for stanfit objects

Description

The default plot shows posterior 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).

Usage

## S3 method for class 'stanfit,missing':
plot(x, ..., plotfun)

Arguments

x
An instance of class stanfit.
plotfun
A character string naming the plotting function to apply to the stanfit object. If plotfun is missing, the default is to call stan_plot, which generates a plot of credible interval
...
Optional arguments to plotfun.

Value

  • A ggplot object that can be further customized using the ggplot2 package.

See Also

List of RStan plotting functions, Plot options

Examples

Run this code
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")

Run the code above in your browser using DataLab