← Back to Index

Proof of Concept / Bayesian Inference

Bayesian Market Share
Forecasting

Dirichlet-Multinomial Posterior Updating for 2L mCRC

A Bayesian forecasting engine that updates market share estimates in real time as prescribing data accumulates. Starting from analyst consensus priors encoded as Dirichlet distributions, the model performs conjugate posterior updating with each month of observed data — producing calibrated uncertainty intervals from Day 1 and progressively sharper forecasts as evidence grows. Built entirely in-browser with no backend dependencies.

Dirichlet DistributionConjugate PriorsPosterior UpdatingCredible IntervalsKL DivergenceMarket Forecasting

Disclaimer: This is a proof-of-concept demonstration using synthetic prescribing data and simulated market dynamics. All market share figures, brand names, and competitive scenarios are illustrative. "Lumivara" is a fictional product. This tool does NOT represent actual commercial data, forecasts, or strategies of any pharmaceutical company. Not intended for investment or commercial decisions.

Running Bayesian market share analysis...

Technical Architecture

Dirichlet-Multinomial Model

The Dirichlet distribution is the conjugate prior for the Multinomial likelihood. Each month's prescribing counts update the posterior via simple addition: alpha' = alpha + n. This closed-form update eliminates MCMC overhead while providing exact posterior inference over market share proportions.

Marginal Beta Densities

Each brand's marginal posterior is Beta(alpha_i, alpha_0 - alpha_i). Log-space computation via Lanczos approximation ensures numerical stability for large alpha values that emerge after months of data accumulation. 200-point density curves enable smooth visualization.

Surprise Detection

KL divergence between consecutive posteriors quantifies 'surprise' — months where observed prescribing data significantly shifted beliefs. Computed using the digamma function with asymptotic series expansion (psi(x) ~ ln(x) - 1/2x - 1/12x^2) and recursion for small arguments.

References

  • Minka T. Estimating a Dirichlet distribution. Technical Report, MIT. 2000 (revised 2003).
  • Frigyik BA, Kapila A, Gupta MR. Introduction to the Dirichlet Distribution and Related Processes. Technical Report UWEETR-2010-0006, University of Washington. 2010.
  • Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB. Bayesian Data Analysis. 3rd ed. CRC Press; 2013.
  • Berger RL, et al. Regorafenib versus placebo in patients with metastatic colorectal cancer (CORRECT): updated results. Lancet Oncol. 2013;14(8):733-740.
  • Mayer RJ, et al. Randomized trial of TAS-102 for refractory metastatic colorectal cancer (RECOURSE). N Engl J Med. 2015;372(20):1909-1919.
  • Ahrens JH, Dieter U. Computer methods for sampling from gamma, beta, Poisson and binomial distributions. Computing. 1974;12(3):223-246.

Daniel Tran, PharmD

UC San Diego — Skaggs School of Pharmacy

Source code MIT. Content © 2026 Daniel Tran (CC BY-NC-SA 4.0).