Performs Bayesian disaggregation of an aggregated time series (e.g., CPI) into \(K\) components using one of four deterministic update rules: weighted, multiplicative, dirichlet, adaptive.
bayesian_disaggregate(
path_cpi,
path_weights,
method = c("weighted", "multiplicative", "dirichlet", "adaptive"),
lambda = 0.7,
gamma = 0.1,
coh_mult = 3,
coh_const = 0.5,
stab_a = 1000,
stab_b = 10,
stab_kappa = 50,
likelihood_pattern = "recent"
)A list with:
yearsInteger vector of years used.
industriesCharacter vector of sector/column names.
priorTibble prior \(T \times (1+K)\) with Year then sectors.
likelihood_tTibble likelihood over time (same shape as prior).
likelihoodTibble Sector, L (length \(K\)).
posteriorTibble posterior \(T \times (1+K)\) (rows sum to 1).
metricsTibble with hyperparameters + coherence, stability,
interpretability, efficiency, composite, T, K.
Path to the CPI Excel file. Must contain at least the
columns date and value (case/locale tolerant in read_cpi()).
Path to the Excel file with the baseline weight matrix (prior): either \(T \times K\) (years in rows, sectors in columns) or a length-\(K\) vector (constant across time). Rows are renormalized to the simplex.
Disaggregation method: "weighted", "multiplicative",
"dirichlet", or "adaptive".
Weight for the "weighted" method in \([0,1]\). Ignored otherwise.
Uncertainty factor for the "dirichlet" method (\(> 0\)).
Multiplier for the coherence increment \(\Delta\rho\).
Constant offset for coherence, truncated to \([0,1]\).
Sensitivity for row-sum deviation penalty \(| \sum w - 1 |\).
Sensitivity for negative-values penalty (count of negatives).
Sensitivity for temporal variation (average \(|\Delta|\)).
Temporal spreading pattern for the likelihood:
"constant", "recent", "linear", or "bell".
Assumptions: (i) prior/posterior rows lie on the simplex; (ii) no MCMC is used,
updates are analytic/deterministic; (iii) read_* helpers coerce benign
formatting issues and error on malformed inputs.
read_cpi, read_weights_matrix,
compute_L_from_P, spread_likelihood,
posterior_weighted, posterior_multiplicative,
posterior_dirichlet, posterior_adaptive,
coherence_score, stability_composite,
interpretability_score
# \donttest{
# Minimal synthetic run (no files):
T <- 6; K <- 4
P <- matrix(rep(1/K, T*K), nrow = T)
L <- runif(K); L <- L/sum(L)
LT <- spread_likelihood(L, T, "recent")
W <- posterior_weighted(P, LT, lambda = 0.7)
# }
Run the code above in your browser using DataLab