% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model-averaging-plots.R
\name{plot_posterior}
\alias{plot_posterior}
\title{Plot samples from the mixed posterior distributions}
\usage{
plot_posterior(
  samples,
  parameter,
  plot_type = "base",
  prior = FALSE,
  n_points = 1000,
  n_samples = 10000,
  force_samples = FALSE,
  individual = FALSE,
  show_figures = NULL,
  transformation = NULL,
  transformation_arguments = NULL,
  transformation_settings = FALSE,
  rescale_x = FALSE,
  par_name = NULL,
  effect_direction = "positive",
  dots_prior = list(),
  data = NULL,
  show_data = FALSE,
  dots_data = list(),
  legend = TRUE,
  legend_title = NULL,
  legend_labels = NULL,
  legend_position = NULL,
  ...
)
}
\arguments{
\item{samples}{samples from a posterior distribution for a
parameter generated by \link{mix_posteriors} or \link{as_mixed_posteriors}.}

\item{parameter}{parameter name to be plotted. Use \code{"PETPEESE"}
for PET-PEESE plot with parameters \code{"PET"} and \code{"PEESE"},
and \code{"weightfunction"} for plotting a weightfunction with
parameters \code{"omega"}.}

\item{plot_type}{whether to use a base plot \code{"base"}
or ggplot2 \code{"ggplot"} for plotting.}

\item{prior}{whether prior distribution should be added to the figure.
When samples were prepared with \code{as_mixed_posteriors(..., transform_scaled = TRUE)},
the transformed prior samples are automatically used.}

\item{n_points}{number of equally spaced points
in the \code{x_range} if \code{x_seq} is unspecified}

\item{n_samples}{number of samples from the prior
distribution if the density cannot be obtained
analytically (or if samples are forced with
\code{force_samples = TRUE})}

\item{force_samples}{should prior be sampled instead
of obtaining analytic solution whenever possible}

\item{individual}{should individual densities be returned
(e.g., in case of weightfunction)}

\item{show_figures}{which figures should be returned in case of
multiple plots are generated. Useful when priors for the omega
parameter are plotted and \code{individual = TRUE}.}

\item{transformation}{transformation to be applied
to the prior distribution. Either a character
specifying one of the prepared transformations:
\describe{
\item{lin}{linear transformation in form of \code{a + b*x}}
\item{tanh}{hyperbolic tangent transformation}
\item{exp}{exponential transformation}
}, or a list containing the transformation function \code{fun},
inverse transformation function \code{inv}, and derivative of the
transformation \code{jac}, evaluated on the original support. See examples
for details.}

\item{transformation_arguments}{a list with named arguments for
the \code{transformation}}

\item{transformation_settings}{boolean indicating whether the
settings the \code{x_seq} or \code{x_range} was specified on
the transformed support}

\item{rescale_x}{allows to rescale x-axis in case a
weightfunction is plotted.}

\item{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.}

\item{effect_direction}{direction of the effect for PET-PEESE
regression. Use \code{"positive"} (default) for
\code{mu + PET*se + PEESE*se^2} or \code{"negative"} for
\code{mu - PET*se - PEESE*se^2}.}

\item{dots_prior}{additional arguments for the prior distribution plot}

\item{data}{optional numeric vector of observed p-values in \code{[0, 1]}, or
a data frame with a \code{p} column. Used only for weightfunction plots.}

\item{show_data}{whether observed p-values should be shown as rug marks on
the weightfunction x-axis.}

\item{dots_data}{additional styling arguments for observed p-value rug marks.
Supports \code{col}/\code{color}, \code{alpha}, \code{lwd}/\code{linewidth},
\code{side}/\code{rug_side}, and \code{height}/\code{rug_height}.}

\item{legend}{whether factor legends should be drawn.}

\item{legend_title}{optional title for factor legends.}

\item{legend_labels}{optional labels for factor legend levels.}

\item{legend_position}{optional legend position for factor legends.}

\item{...}{additional arguments}
}
\value{
\code{plot_posterior} returns either \code{NULL} or
an object of class 'ggplot' if plot_type is \code{plot_type = "ggplot"}.
}
\description{
Plot samples from the mixed posterior distributions
}
\details{
When using scaled predictors (via \code{formula_scale_list} in \link{JAGS_fit}),
you can plot posteriors on the original (unscaled) scale by preparing samples with
\code{as_mixed_posteriors(..., transform_scaled = TRUE)}. The function automatically
detects this and uses the pre-computed transformed prior samples when \code{prior = TRUE}.
}
\seealso{
\code{\link[=prior]{prior()}} \code{\link[=lines_prior_list]{lines_prior_list()}}  \code{\link[=geom_prior_list]{geom_prior_list()}}
}
