Learn R Programming

BayesianDisaggregation (version 0.1.2)

posterior_weighted: Weighted-average posterior (convex combination)

Description

Computes \(W = \lambda P + (1-\lambda)\,LT\) row-wise and renormalizes each row to the unit simplex (suma 1). Expects matrices no negativas con las mismas dimensiones \(T \times K\).

Usage

posterior_weighted(P, LT, lambda = 0.7)

Value

Posterior matrix \(W\) (\(T \times K\)), filas suman 1.

Arguments

P

Prior matrix (\(T \times K\)); filas no negativas.

LT

Likelihood matrix (\(T \times K\)); filas no negativas.

lambda

Mixing weight in \([0,1]\) (default 0.7).

See Also

posterior_multiplicative, posterior_dirichlet, posterior_adaptive

Examples

Run this code
T <- 5; K <- 3
P  <- matrix(runif(T*K), T); P  <- P / rowSums(P)
LT <- matrix(runif(T*K), T); LT <- LT / rowSums(LT)
W <- posterior_weighted(P, LT, 0.6)
stopifnot(all(abs(rowSums(W)-1) < 1e-12))

Run the code above in your browser using DataLab