Plots the prior density of a quantity that is a linear combination of fitted coordinates, as returned by parameter_prior_density() and JAGS_formula_prior_density(): the continuous part as a curve, and the point masses as arrows on a secondary probability axis.

# S3 method for class 'prior_linear_density'
plot(
  x,
  plot_type = "base",
  n_points = 1000,
  xlim = NULL,
  transformation = NULL,
  transformation_arguments = NULL,
  transformation_settings = FALSE,
  par_name = NULL,
  ...
)

Arguments

x

a prior_linear_density object.

plot_type

whether to use a base plot "base" or ggplot2 "ggplot" for plotting.

n_points

number of plotting points. A density that needs numerical integration (a Gaussian convolution, a scale mixture, or a sum of two non-normal terms) is plotted at no more than 200 equally spaced points plus its support bounds, jumps, peaks and atoms.

xlim

optional plotting range of length two, on the untransformed scale (on the transformed scale when transformation_settings = TRUE).

transformation

optional transformation applied to the density: one of the prepared transformations of density.prior() ("lin", "tanh", "exp", "exp_lin"), or a list with the functions fun, inv, and jac.

transformation_arguments

optional list with named arguments for the transformation.

transformation_settings

whether xlim is supplied on the transformed scale.

par_name

optional label of the x-axis.

...

additional graphical arguments, as in plot.prior(). For mixed continuous and point densities, ylim controls the density axis, ylim2 the probability axis, ylab2 its label, and scale_y2 the scaling factor of the probability axis. add = TRUE adds the density to the current base plot, which keeps the scaling of its probability axis, or, for plot_type = "ggplot", returns an overlay that is added to an existing prior plot with +.

Value

plot.prior_linear_density() returns an object of class 'ggplot' if plot_type = "ggplot" (an overlay of class BayesTools_prior_overlay if add = TRUE), and otherwise draws the base plot and returns NULL invisibly.

Details

Continuous parts are drawn as curves and point masses as arrows on the probability axis, as for the priors of plot.prior(). A continuous part without an exact route that cannot be resolved is omitted with a warning of class BayesTools_prior_curve_unavailable (also BayesTools_plot_condition), and the declared point masses are still drawn. A density with neither a curve nor a point mass in the plotted range stops with an error.