% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/posterior.R
\name{getPosterior}
\alias{getPosterior}
\title{getPosterior}
\usage{
getPosterior(
  prior_list,
  data = NULL,
  mu_hat = NULL,
  S_hat = NULL,
  calc_ess = FALSE,
  probability_scale = attr(data, "probability_scale")
)
}
\arguments{
\item{prior_list}{a prior list with information about the prior to be used for every dose group}

\item{data}{dataframe containing the information of dose and response. Also a simulateData object can be provided. Default NULL.}

\item{mu_hat}{vector of estimated mean values (per dose group). Default NULL.}

\item{S_hat}{covariance matrix specifying the (estimated) variability.
The variance-covariance matrix should be provided and the dimension of the matrix needs to match the number of dose groups. Default NULL.}

\item{calc_ess}{boolean variable, indicating whether effective sample size should be calculated. Default FALSE.}

\item{probability_scale}{A boolean to specify if the trial has a continuous or a binary outcome. Setting to TRUE will transform calculations from the logit scale to the probability scale, which can be desirable for a binary outcome. Default \code{attr(data, "probability_scale")}.}
}
\value{
posterior_list, a posterior list object is returned with information about (mixture) posterior distribution per dose group (more detailed information about the conjugate posterior in case of covariance input for S_hat is provided in the attributes)
}
\description{
Either the patient level data or both mu_hat as well as S_hat must to be provided.
If patient level data is provided mu_hat and S_hat are calculated within the function using a linear model.
This function calculates the posterior distribution. Depending on the input for S_hat this step is either performed for every dose group independently via the RBesT function postmix() or the mvpostmix() function of the DoseFinding package is utilized.
In the latter case conjugate posterior mixture of multivariate normals are calculated (DeGroot 1970, Bernardo and Smith 1994)
}
\details{
Kindly note that one can sample from the \code{posterior_list} with \code{lapply(posterior_list, RBesT::rmix, n = 10)}.

For binary endpoints, if separation occurs (for example, when one treatment arm has only responders or only non‑responders), we use penalized logistic regression with Firth’s correction to prevent convergence issues and obtain more stable estimates.
See the references for additional details.
}
\examples{
prior_list <- list(Ctrl = RBesT::mixnorm(comp1 = c(w = 1, m = 0, s = 5), sigma = 2),
                   DG_1 = RBesT::mixnorm(comp1 = c(w = 1, m = 1, s = 12), sigma = 2),
                   DG_2 = RBesT::mixnorm(comp1 = c(w = 1, m = 1.2, s = 11), sigma = 2) ,
                   DG_3 = RBesT::mixnorm(comp1 = c(w = 1, m = 1.3, s = 11), sigma = 2) ,
                   DG_4 = RBesT::mixnorm(comp1 = c(w = 1, m = 2, s = 13), sigma = 2))
                   
mu_hat <- c(0, 1, 1.5, 2, 2.5)
S_hat  <- diag(c(5, 4, 6, 7, 8)^2)

posterior_list <- getPosterior(
   prior_list = prior_list,
   mu_hat     = mu_hat,
   S_hat      = S_hat)

summary(posterior_list)

}
\references{
BERNARDO, Jl. M., and Smith, AFM (1994). Bayesian Theory. 81.

Heinze, G. & Schemper, M. (2002). A solution to the problem of separation
in logistic regression. \emph{Statistics in Medicine}, 21(16), 2409–2419.

Liu et al. (2022). Commentary: analyzing binary data using MCPMod when zero counts are expected.
\emph{arXiv}, 2202.08781, https://arxiv.org/abs/2202.08781
}
