Learn R Programming

powerprior (version 1.0.0)

posterior_univariate: Posterior Obtained by Updating Power Prior with Current Data (Univariate)

Description

Updates a power prior with current trial data to obtain the posterior distribution.

Usage

posterior_univariate(powerprior, current_data)

Value

A list of class "posterior_univariate" containing:

mu_star

Posterior mean parameter

kappa_star

Posterior precision parameter

nu_star

Posterior degrees of freedom

sigma2_star

Posterior scale parameter

n

Sample size of current data

ybar

Sample mean of current data

Sy

Sum of squared deviations of current data

powerprior

Original power prior object

Arguments

powerprior

Object of class "powerprior_univariate" from powerprior_univariate()

current_data

Numeric vector of current trial observations. Must contain at least 2 observations. Missing values (NAs) are automatically removed.

Details

Posterior Updating

Given a power prior distribution P(\(\mu\), \(\sigma^2\) | x, \(a_0\)) and new current data y, the posterior distribution is computed by combining the power prior with the likelihood of the current data using Bayes' theorem.

The conjugate structure ensures the posterior remains a NIX distribution. For both informative and vague initial priors, the updating follows standard conjugate rules, leveraging the fact that both the power prior and likelihood are in the NIX family.

This eliminates the computational burden of MCMC and allows direct posterior inference and sampling (see sample_posterior_univariate).

Examples

Run this code
# Generate data
historical <- rnorm(50, mean = 10, sd = 2)
current <- rnorm(30, mean = 10.5, sd = 2)

# Compute power prior and posterior
pp <- powerprior_univariate(historical, a0 = 0.5)
posterior <- posterior_univariate(pp, current)
print(posterior)

# With informative prior
pp_inform <- powerprior_univariate(
  historical, a0 = 0.5,
  mu0 = 10, kappa0 = 1, nu0 = 3, sigma2_0 = 4
)
posterior_inform <- posterior_univariate(pp_inform, current)
print(posterior_inform)

Run the code above in your browser using DataLab