plot.prior {BayesTools} | R Documentation |
Plots a prior object
Description
Plots a prior object
Usage
## S3 method for class 'prior'
plot(
x,
plot_type = "base",
x_seq = NULL,
xlim = NULL,
x_range_quant = NULL,
n_points = 1000,
n_samples = 10000,
force_samples = FALSE,
transformation = NULL,
transformation_arguments = NULL,
transformation_settings = FALSE,
show_figures = if (individual) -1 else NULL,
individual = FALSE,
rescale_x = FALSE,
par_name = NULL,
...
)
Arguments
x |
a prior |
plot_type |
whether to use a base plot |
x_seq |
sequence of x coordinates |
xlim |
x plotting range |
x_range_quant |
quantile used for
automatically obtaining |
n_points |
number of equally spaced points
in the |
n_samples |
number of samples from the prior
distribution if the density cannot be obtained
analytically (or if samples are forced with
|
force_samples |
should prior be sampled instead of obtaining analytic solution whenever possible |
transformation |
transformation to be applied to the prior distribution. Either a character specifying one of the prepared transformations:
, or a list containing the transformation function |
transformation_arguments |
a list with named arguments for
the |
transformation_settings |
boolean indicating whether the
settings the |
show_figures |
which figures should be returned in case of
multiple plots are generated. Useful when priors for the omega
parameter are plotted and |
individual |
should individual densities be returned (e.g., in case of weightfunction) |
rescale_x |
allows to rescale x-axis in case a weightfunction is plotted. |
par_name |
a type of parameter for which the prior is specified. Only relevant if the prior corresponds to a mu parameter that needs to be transformed. |
... |
additional arguments |
Value
plot.prior
returns either NULL
or
an object of class 'ggplot' if plot_type is plot_type = "ggplot"
.
See Also
prior()
lines.prior()
geom_prior()
Examples
# create some prior distributions
p0 <- prior(distribution = "point", parameters = list(location = 0))
p1 <- prior(distribution = "normal", parameters = list(mean = 0, sd = 1))
p2 <- prior(distribution = "normal", parameters = list(mean = 0, sd = 1), truncation = list(0, Inf))
# a default plot
plot(p0)
# manipulate line thickness and color, change the parameter name
plot(p1, lwd = 2, col = "blue", par_name = bquote(mu))
# use ggplot
plot(p2, plot_type = "ggplot")
# utilize the ggplot prior geom
plot(p2, plot_type = "ggplot", xlim = c(-2, 2)) + geom_prior(p1, col = "red", lty = 2)
# apply transformation
plot(p1, transformation = "exp")