Learn R Programming

powerprior (version 1.0.0)

posterior_multivariate: Posterior Obtained by Updating Power Prior with Current Data (Multivariate)

Description

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

Usage

posterior_multivariate(powerprior, current_data)

Value

A list of class "posterior_multivariate" containing:

mu_star

Posterior mean vector

kappa_star

Posterior precision parameter

nu_star

Posterior degrees of freedom

Lambda_star

Posterior scale matrix

n

Sample size of current data

p

Dimension of data

ybar

Sample mean vector of current data

Sy

Sum of squares and crossproducts matrix for current data

powerprior

Original power prior object

Arguments

powerprior

Object of class "powerprior_multivariate" from powerprior_multivariate()

current_data

Matrix or data frame of current observations. Must have the same number of columns as the historical data used to create the power prior. Rows represent observations, columns represent variables.

Details

Posterior Updating in the Multivariate Setting

Given a power prior P(\(\mu\), \(\Sigma\) | X, \(a_0\)) and new current data Y, the posterior distribution combines both through Bayes' theorem. The conjugate NIW structure ensures the posterior remains a NIW distribution with closed-form parameters.

The updating mechanism mirrors the univariate case but extends to handle the covariance matrix structure. The scale matrix \(\Lambda^*\) incorporates:

  1. Discounted historical sum of squares and crossproducts (\(a_0\) * S_x)

  2. Prior scale information (\(\Lambda_0\), if using informative prior)

  3. Current data sum of squares and crossproducts (S_y)

  4. Disagreement terms that increase uncertainty when historical and current means differ

The posterior mean vector is a precision-weighted average of the historical mean, prior mean (if provided), and current mean, allowing for flexible incorporation of multiple information sources with different precisions.

Examples

Run this code
library(MASS)
Sigma_true <- matrix(c(4, 1, 1, 2), 2, 2)
historical <- mvrnorm(50, mu = c(10, 5), Sigma = Sigma_true)
current <- mvrnorm(30, mu = c(10.5, 5.2), Sigma = Sigma_true)

# With vague prior
pp <- powerprior_multivariate(historical, a0 = 0.5)
posterior <- posterior_multivariate(pp, current)
print(posterior)

# With informative prior
pp_inform <- powerprior_multivariate(
  historical, a0 = 0.5,
  mu0 = c(10, 5), kappa0 = 1, nu0 = 5, Lambda0 = diag(2)
)
posterior_inform <- posterior_multivariate(pp_inform, current)
print(posterior_inform)

Run the code above in your browser using DataLab