simulate_priors {abtest} | R Documentation |
Simulate from Parameter Priors
Description
Function for simulating from the parameter prior distributions.
Usage
simulate_priors(
nsamples,
prior_par = list(mu_psi = 0, sigma_psi = 1, mu_beta = 0, sigma_beta = 1),
hypothesis = "H1"
)
Arguments
nsamples |
number of samples. |
prior_par |
list with prior parameters. This list needs to contain the
following elements: |
hypothesis |
character specifying whether to sample from a two-sided prior (i.e., "H1"), a one-sided prior with lower truncation point (i.e., "H+"), or a one-sided prior with upper truncation point (i.e., "H-"). |
Value
a data frame with prior samples for the following quantities (see
?ab_test
for a description of the underlying model):
-
beta
: prior samples for the grand mean of the log odds. -
psi
: prior samples for the log odds ratio. -
p1
: prior samples for the latent "success" probability in the control group. -
p2
: prior samples for the latent "success" probability in the experimental group. -
logor
: prior samples for the log odds ratio (identical topsi
, only included for easier reference). -
or
: prior samples for the odds ratio. -
rrisk
: prior samples for the relative risk (i.e., the ratio of the "success" probability in the experimental and the control condition). -
arisk
: prior samples for the absolute risk (i.e., the difference of the "success" probability in the experimental and control condition)
.
Author(s)
Quentin F. Gronau
Examples
# prior parameters
prior_par <- list(mu_psi = 0, sigma_psi = 1,
mu_beta = 0, sigma_beta = 1)
# obtain prior samples
samples <- simulate_priors(nsamples = 1000, prior_par = prior_par)
# plot, e.g., prior samples for absolute risk
hist(samples$arisk)