Learn R Programming

ppRep (version 0.42.3)

postPP: Posterior density of effect size and power parameter

Description

This function computes the posterior density of effect size \(\theta\) and power parameter \(\alpha\) assuming a normal likelihood for original and replication effect estimate. A power prior for \(\theta\) is constructed by updating an initial normal prior \(\theta \sim \mathrm{N}(\code{m}, \code{v})\) with the likelihood of the original data raised to the power of \(\alpha\). A marginal beta prior \(\alpha \sim \mbox{Beta}(\code{x},\code{y})\) is assumed.

Usage

postPP(theta, alpha, tr, sr, to, so, x = 1, y = 1, m = 0, v = Inf, ...)

Value

Posterior density

Arguments

theta

Effect size. Has to be of length one or the same length as alpha.

alpha

Power parameter. Has to be of length one or the same length as theta.

tr

Effect estimate of the replication study.

sr

Standard error of the replication effect estimate.

to

Effect estimate of the original study.

so

Standard error of the replication effect estimate.

x

Number of successes parameter of beta prior for \(\alpha\). Defaults to 1.

y

Number of failures parameter of beta prior for \(\alpha\). Defaults to 1.

m

Mean parameter of initial normal prior for \(\theta\). Defaults to 0.

v

Variance parameter of initial normal prior for \(\theta\). Defaults to Inf (uniform prior).

...

Additional arguments passed to stats::integrate.

Author

Samuel Pawel

See Also

postPPalpha, postPPtheta, plotPP

Examples

Run this code
alpha <- seq(0, 1, length.out = 200)
theta <- seq(0, 0.3, length.out = 200)
parGrid <- expand.grid(alpha = alpha, theta = theta)
postdens <- postPP(theta = parGrid$theta, alpha = parGrid$alpha, tr = 0.1,
                   sr = 0.05, to = 0.2, so = 0.05)
postdensMat <- matrix(data = postdens, ncol = 200, byrow = TRUE)
filled.contour(x = theta, y = alpha, z = postdensMat,
               xlab = bquote("Effect size" ~ theta),
               ylab = bquote("Power parameter" ~ alpha), nlevels = 15,
               color.palette = function(n) hcl.colors(n = n, palette = "viridis"))

Run the code above in your browser using DataLab