Source paper: Keil, Alexander P., et al. "A Bayesian approach to the g-formula." Statistical Methods in Medical Research (2015): 0962280217694665.
Note that the code here fixes one bug from the Stan code (which was not used in the published analysis) and notates the applied example code to more explicitly to define the causal effect being estimated