bayesassurance: An R Package for Calculating Sample Size and Bayesian Assurance

In this paper, we present bayesassurance, an R package designed for computing Bayesian assurance criteria which can be used to determine sample size in Bayesian inference setting. The functions included in the R package offer a two-stage framework using design priors to specify the population from which the data will be collected and analysis priors to fit a Bayesian model. We also demonstrate that frequentist sample size calculations are exactly reproduced as special cases of evaluating Bayesian assurance functions using appropriately specified priors.

Jane Pan (University of California, Los Angeles) , Sudipto Banerjee (University of California, Los Angeles)

0.1 Supplementary materials

Supplementary materials are available in addition to this article. It can be downloaded at

C. J. Adcock. Sample size determination: A review. The Statistician, 46(2): 1997.
J. O. Berger. Statistical decision theory and bayesian analysis. New York, NY: Springer New York, 1985.
A. E. Gelfand and F. Wang. A simulation based approach to bayesian sample size determination for performance under a given model and for separating models. Statistical Science, 17(2): 2002.
L. Y. T. Inoue, D. A. Berry and G. Parmigiani. Relationship between bayesian and frequentist sample size determination. The American Statistician, 59(1): 2005.
L. Joseph and P. Belisle. Bayesian sample size determination for normal means and differences between normal means. The Statistician, 46(2): 1997.
L. Joseph and P. Belisle. Package SampleSizeMeans. 2012. URL SampleSizeMeans/SampleSizeMeans.pdf. R package version 1.1.
L. Joseph and P. Belisle. Package SampleSizeProportions. 2009. URL R package version 1.0.
L. Joseph, R. D. Berger and P. Belisle. Bayesian and mixed bayesian/likelihood criteria for sample size determination. Statistics in Medicine, 16(7): 1997.
L. Joseph, D. B. Wolfson and R. du Berger. Sample size calculations for binomial proportions via highest posterior density intervals. The Statistician, 44(2): 1995.
D. V. Lindley. The choice of sample size. The Statistician, 46(2): 1997.
P. Müller and G. Parmigiani. Optimal design via curve fitting of monte carlo experiments. Journal of the American Statistical Association, 90(432): 1995.
A. O’Hagan and J. W. Stevens. Bayesian assessment of sample size for clinical trials of cost-effectiveness. Medical Decision Making, 21(3): 2001.
J. Pan and S. Banerjee. Package bayesassurance. 2022. URL R package version 0.1.0.
G. Parmigiani. Modeling in medical decision making: A bayesian approach. Hoboken, NJ: Wiley, 2002.
T. Pham-Gia. On bayesian analysis, bayesian decision theory and the sample size problem. The Statistician, 46(2): 1997.
E. Rahme, Lawrence and T. W. Gyorkos. Bayesian sample size determination for estimating binomial parameters from data subject to misclassification. Journal of Royal Statistical Society, 49(1): 2000.
H. Raiffa and R. Schlaifer. Applied statistical decision theory. Massachusetts: Harvard University Graduate School of Business Administration (Division of Research), 1961.
E. M. Reyes and S. K. Ghosh. Bayesian average error based approach to sample size calculations for hypothesis testing. Biopharm, 23(3): 2013.
H. Wickham. ggplot2: Elegant graphics for data analysis. Springer-Verlag New York, 2016. URL



Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Pan & Banerjee, "bayesassurance: An R Package for Calculating Sample Size and Bayesian Assurance", The R Journal, 2023

BibTeX citation

  author = {Pan, Jane and Banerjee, Sudipto},
  title = {bayesassurance: An R Package for Calculating Sample Size and Bayesian Assurance},
  journal = {The R Journal},
  year = {2023},
  note = {},
  doi = {10.32614/RJ-2023-066},
  volume = {15},
  issue = {3},
  issn = {2073-4859},
  pages = {138-158}