calc_post_norm {beastt} | R Documentation |
Calculate Posterior Normal
Description
Calculate a posterior distribution that is normal (or a mixture of normal components). Only the relevant treatment arms from the internal dataset should be read in (e.g., only the control arm if constructing a posterior distribution for the control mean).
Usage
calc_post_norm(internal_data, response, prior, internal_sd = NULL)
Arguments
internal_data |
This can either be a propensity score object or a tibble of the internal data. |
response |
Name of response variable |
prior |
A distributional object corresponding to a normal distribution, a t distribution, or a mixture distribution of normal and/or t components |
internal_sd |
Standard deviation of internal response data if
assumed known. It can be left as |
Details
For a given arm of an internal trial (e.g., the control arm or an
active treatment arm) of size , suppose the response data are normally
distributed such that
,
.
If
is assumed known, the posterior distribution for
is written as
where is the
likelihood of the response data from the internal arm and
is a prior distribution on
(either a normal distribution, a
distribution, or a mixture distribution with an arbitrary number of
normal and/or
components). Any
components of the prior for
are approximated with a mixture of two normal distributions.
If is unknown, the marginal posterior distribution for
is instead written as
In this case, the prior for is chosen to be
such that
becomes a non-standardized
distribution. This integrated likelihood
is then approximated with a mixture of two normal distributions.
If internal_sd
is supplied a positive value and prior
corresponds to a
single normal distribution, then the posterior distribution for
is a normal distribution. If
internal_sd = NULL
or if other types of prior
distributions are specified (e.g., mixture or t distribution), then the
posterior distribution is a mixture of normal distributions.
Value
distributional object
Examples
library(distributional)
library(dplyr)
post_treated <- calc_post_norm(internal_data = filter(int_norm_df, trt == 1),
response = y,
prior = dist_normal(50, 10),
internal_sd = 0.15)