├── LICENSE ├── codecov.yml ├── tests ├── testthat.R └── testthat │ ├── test-util.R │ ├── test-bandit.R │ ├── test-dists.R │ ├── test-uniform.R │ ├── test-exponential.R │ ├── test-poisson.R │ ├── test-normal.R │ ├── test-bernoulliC.R │ ├── test-lognormal.R │ ├── test-poissonC.R │ ├── test-bernoulli.R │ ├── test-generics.R │ └── test-combine.R ├── docs ├── reference │ ├── combine-1.png │ ├── combine-2.png │ ├── combine-3.png │ ├── combine-4.png │ ├── combine-5.png │ ├── combine-6.png │ ├── combine-7.png │ ├── combine-8.png │ ├── combine-9.png │ ├── bayesTest-1.png │ ├── bayesTest-10.png │ ├── bayesTest-11.png │ ├── bayesTest-12.png │ ├── bayesTest-13.png │ ├── bayesTest-14.png │ ├── bayesTest-15.png │ ├── bayesTest-16.png │ ├── bayesTest-17.png │ ├── bayesTest-18.png │ ├── bayesTest-19.png │ ├── bayesTest-2.png │ ├── bayesTest-20.png │ ├── bayesTest-21.png │ ├── bayesTest-22.png │ ├── bayesTest-23.png │ ├── bayesTest-24.png │ ├── bayesTest-25.png │ ├── bayesTest-26.png │ ├── bayesTest-27.png │ ├── bayesTest-28.png │ ├── bayesTest-29.png │ ├── bayesTest-3.png │ ├── bayesTest-30.png │ ├── bayesTest-31.png │ ├── bayesTest-32.png │ ├── bayesTest-33.png │ ├── bayesTest-34.png │ ├── bayesTest-35.png │ ├── bayesTest-36.png │ ├── bayesTest-37.png │ ├── bayesTest-38.png │ ├── bayesTest-39.png │ ├── bayesTest-4.png │ ├── bayesTest-40.png │ ├── bayesTest-41.png │ ├── bayesTest-42.png │ ├── bayesTest-43.png │ ├── bayesTest-44.png │ ├── bayesTest-45.png │ ├── bayesTest-46.png │ ├── bayesTest-47.png │ ├── bayesTest-48.png │ ├── bayesTest-49.png │ ├── bayesTest-5.png │ ├── bayesTest-50.png │ ├── bayesTest-51.png │ ├── bayesTest-52.png │ ├── bayesTest-53.png │ ├── bayesTest-54.png │ ├── bayesTest-55.png │ ├── bayesTest-56.png │ ├── bayesTest-57.png │ ├── bayesTest-58.png │ ├── bayesTest-59.png │ ├── bayesTest-6.png │ ├── bayesTest-60.png │ ├── bayesTest-61.png │ ├── bayesTest-62.png │ ├── bayesTest-63.png │ ├── bayesTest-64.png │ ├── bayesTest-65.png │ ├── bayesTest-66.png │ ├── bayesTest-7.png │ ├── bayesTest-8.png │ ├── bayesTest-9.png │ ├── combine-10.png │ ├── combine-11.png │ ├── combine-12.png │ ├── plotBeta-1.png │ ├── plotBeta-10.png │ ├── plotBeta-11.png │ ├── plotBeta-12.png │ ├── plotBeta-2.png │ ├── plotBeta-3.png │ ├── plotBeta-4.png │ ├── plotBeta-5.png │ ├── plotBeta-6.png │ ├── plotBeta-7.png │ ├── plotBeta-8.png │ ├── plotBeta-9.png │ ├── plotGamma-1.png │ ├── plotGamma-10.png │ ├── plotGamma-11.png │ ├── plotGamma-12.png │ ├── plotGamma-2.png │ ├── plotGamma-3.png │ ├── plotGamma-4.png │ ├── plotGamma-5.png │ ├── plotGamma-6.png │ ├── plotGamma-7.png │ ├── plotGamma-8.png │ ├── plotGamma-9.png │ ├── plotNormal-1.png │ ├── plotNormal-2.png │ ├── plotNormal-3.png │ ├── plotNormal-4.png │ ├── plotNormal-5.png │ ├── plotNormal-6.png │ ├── plotNormal-7.png │ ├── plotNormal-8.png │ ├── plotNormal-9.png │ ├── plotPareto-1.png │ ├── plotPareto-2.png │ ├── plotPareto-3.png │ ├── plotPareto-4.png │ ├── plotPareto-5.png │ ├── plotPareto-6.png │ ├── plotPareto-7.png │ ├── plotPareto-8.png │ ├── plotPareto-9.png │ ├── plotInvGamma-1.png │ ├── plotInvGamma-2.png │ ├── plotInvGamma-3.png │ ├── plotInvGamma-4.png │ ├── plotInvGamma-5.png │ ├── plotInvGamma-6.png │ ├── plotInvGamma-7.png │ ├── plotInvGamma-8.png │ ├── plotInvGamma-9.png │ ├── plotNormal-10.png │ ├── plotNormal-11.png │ ├── plotNormal-12.png │ ├── plotPareto-10.png │ ├── plotPareto-11.png │ ├── plotPareto-12.png │ ├── plotPoisson-1.png │ ├── plotPoisson-10.png │ ├── plotPoisson-11.png │ ├── plotPoisson-12.png │ ├── plotPoisson-2.png │ ├── plotPoisson-3.png │ ├── plotPoisson-4.png │ ├── plotPoisson-5.png │ ├── plotPoisson-6.png │ ├── plotPoisson-7.png │ ├── plotPoisson-8.png │ ├── plotPoisson-9.png │ ├── plot.bayesTest-1.png │ ├── plot.bayesTest-10.png │ ├── plot.bayesTest-11.png │ ├── plot.bayesTest-12.png │ ├── plot.bayesTest-13.png │ ├── plot.bayesTest-14.png │ ├── plot.bayesTest-15.png │ ├── plot.bayesTest-16.png │ ├── plot.bayesTest-17.png │ ├── plot.bayesTest-18.png │ ├── plot.bayesTest-19.png │ ├── plot.bayesTest-2.png │ ├── plot.bayesTest-20.png │ ├── plot.bayesTest-21.png │ ├── plot.bayesTest-22.png │ ├── plot.bayesTest-23.png │ ├── plot.bayesTest-24.png │ ├── plot.bayesTest-25.png │ ├── plot.bayesTest-26.png │ ├── plot.bayesTest-27.png │ ├── plot.bayesTest-28.png │ ├── plot.bayesTest-29.png │ ├── plot.bayesTest-3.png │ ├── plot.bayesTest-30.png │ ├── plot.bayesTest-31.png │ ├── plot.bayesTest-32.png │ ├── plot.bayesTest-33.png │ ├── plot.bayesTest-34.png │ ├── plot.bayesTest-35.png │ ├── plot.bayesTest-36.png │ ├── plot.bayesTest-37.png │ ├── plot.bayesTest-38.png │ ├── plot.bayesTest-39.png │ ├── plot.bayesTest-4.png │ ├── plot.bayesTest-40.png │ ├── plot.bayesTest-41.png │ ├── plot.bayesTest-42.png │ ├── plot.bayesTest-43.png │ ├── plot.bayesTest-44.png │ ├── plot.bayesTest-45.png │ ├── plot.bayesTest-46.png │ ├── plot.bayesTest-47.png │ ├── plot.bayesTest-48.png │ ├── plot.bayesTest-49.png │ ├── plot.bayesTest-5.png │ ├── plot.bayesTest-50.png │ ├── plot.bayesTest-51.png │ ├── plot.bayesTest-52.png │ ├── plot.bayesTest-53.png │ ├── plot.bayesTest-54.png │ ├── plot.bayesTest-55.png │ ├── plot.bayesTest-56.png │ ├── plot.bayesTest-57.png │ ├── plot.bayesTest-58.png │ ├── plot.bayesTest-59.png │ ├── plot.bayesTest-6.png │ ├── plot.bayesTest-60.png │ ├── plot.bayesTest-61.png │ ├── plot.bayesTest-62.png │ ├── plot.bayesTest-63.png │ ├── plot.bayesTest-7.png │ ├── plot.bayesTest-8.png │ ├── plot.bayesTest-9.png │ ├── plotInvGamma-10.png │ ├── plotInvGamma-11.png │ ├── plotInvGamma-12.png │ ├── plotLogNormal-1.png │ ├── plotLogNormal-10.png │ ├── plotLogNormal-11.png │ ├── plotLogNormal-12.png │ ├── plotLogNormal-2.png │ ├── plotLogNormal-3.png │ ├── plotLogNormal-4.png │ ├── plotLogNormal-5.png │ ├── plotLogNormal-6.png │ ├── plotLogNormal-7.png │ ├── plotLogNormal-8.png │ ├── plotLogNormal-9.png │ ├── plotNormalInvGamma-1.png │ ├── rename.html │ └── grab.html ├── articles │ ├── extra │ │ └── priors_blog │ │ │ ├── bern-1.png │ │ │ ├── bern-2.png │ │ │ ├── bern-3.png │ │ │ ├── bern-4.png │ │ │ ├── bern-5.png │ │ │ └── strong_priors-1.png │ ├── introduction_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-2-2.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-4-2.png │ │ │ ├── unnamed-chunk-4-3.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-6-2.png │ │ │ ├── unnamed-chunk-6-3.png │ │ │ ├── unnamed-chunk-8-1.png │ │ │ └── unnamed-chunk-8-2.png │ └── index.html ├── pkgdown.yml ├── link.svg ├── docsearch.js ├── jquery.sticky-kit.min.js ├── pkgdown.js ├── LICENSE.html ├── authors.html └── LICENSE-text.html ├── vignettes └── extra │ ├── priors_blog │ ├── bern-1.png │ ├── bern-2.png │ ├── bern-3.png │ ├── bern-4.png │ ├── bern-5.png │ └── strong_priors-1.png │ └── priors.Rmd ├── .Rbuildignore ├── .gitignore ├── src ├── init.cpp ├── closedTests.cpp └── RcppExports.cpp ├── .travis.yml ├── bayesAB.Rproj ├── cran-comments.md ├── R ├── RcppExports.R ├── dist-normal.R ├── util.R ├── checks.R ├── dists.R ├── constructors.R ├── bayesAB.R ├── makePlots.R ├── posteriors.R ├── combine.R └── bandit.R ├── man ├── rename.Rd ├── grab.Rd ├── plotPoisson.Rd ├── plotPareto.Rd ├── plotBeta.Rd ├── plotNormal.Rd ├── plotLogNormal.Rd ├── plotGamma.Rd ├── c.bayesTest.Rd ├── plotInvGamma.Rd ├── deployBandit.Rd ├── plotNormalInvGamma.Rd ├── plotDistributions.Rd ├── summary.bayesTest.Rd ├── banditize.Rd ├── plot.bayesTest.Rd ├── combine.Rd └── bayesAB.Rd ├── DESCRIPTION ├── _pkgdown.yml ├── NAMESPACE ├── NEWS.md └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2016 2 | COPYRIGHT HOLDER: Frank Portman 3 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | 3 | ignore: 4 | - R/bandit.R 5 | - src/init.cpp 6 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(bayesAB) 3 | 4 | test_check("bayesAB") 5 | -------------------------------------------------------------------------------- /docs/reference/combine-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-1.png -------------------------------------------------------------------------------- /docs/reference/combine-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-2.png -------------------------------------------------------------------------------- /docs/reference/combine-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-3.png -------------------------------------------------------------------------------- /docs/reference/combine-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-4.png -------------------------------------------------------------------------------- /docs/reference/combine-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-5.png -------------------------------------------------------------------------------- /docs/reference/combine-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-6.png -------------------------------------------------------------------------------- /docs/reference/combine-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-7.png -------------------------------------------------------------------------------- /docs/reference/combine-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-8.png -------------------------------------------------------------------------------- /docs/reference/combine-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-9.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-1.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-10.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-11.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-12.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-13.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-14.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-15.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-16.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-17.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-18.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-19.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-2.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-20.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-21.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-22.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-23.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-24.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-25.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-26.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-27.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-28.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-29.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-3.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-30.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-31.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-32.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-33.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-34.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-35.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-36.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-37.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-38.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-39.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-4.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-40.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-41.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-42.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-43.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-44.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-45.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-46.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-47.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-48.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-49.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-5.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-50.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-51.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-52.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-53.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-54.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-55.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-56.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-57.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-58.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-59.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-6.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-60.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-61.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-62.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-63.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-64.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-65.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-66.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-7.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-8.png -------------------------------------------------------------------------------- /docs/reference/bayesTest-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/bayesTest-9.png -------------------------------------------------------------------------------- /docs/reference/combine-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-10.png -------------------------------------------------------------------------------- /docs/reference/combine-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-11.png -------------------------------------------------------------------------------- /docs/reference/combine-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/combine-12.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-1.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-10.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-11.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-12.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-2.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-3.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-4.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-5.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-6.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-7.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-8.png -------------------------------------------------------------------------------- /docs/reference/plotBeta-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotBeta-9.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-1.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-10.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-11.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-12.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-2.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-3.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-4.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-5.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-6.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-7.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-8.png -------------------------------------------------------------------------------- /docs/reference/plotGamma-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotGamma-9.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-1.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-2.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-3.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-4.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-5.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-6.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-7.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-8.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-9.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-1.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-2.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-3.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-4.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-5.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-6.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-7.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-8.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-9.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-1.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-2.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-3.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-4.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-5.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-6.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-7.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-8.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-9.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-10.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-11.png -------------------------------------------------------------------------------- /docs/reference/plotNormal-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormal-12.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-10.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-11.png -------------------------------------------------------------------------------- /docs/reference/plotPareto-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPareto-12.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-1.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-10.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-11.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-12.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-2.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-3.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-4.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-5.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-6.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-7.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-8.png -------------------------------------------------------------------------------- /docs/reference/plotPoisson-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotPoisson-9.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-1.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-10.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-11.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-12.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-13.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-14.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-15.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-16.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-17.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-18.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-19.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-2.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-20.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-21.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-22.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-23.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-24.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-25.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-26.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-27.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-28.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-29.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-3.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-30.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-31.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-32.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-33.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-34.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-35.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-36.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-37.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-38.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-39.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-4.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-40.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-41.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-42.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-43.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-44.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-45.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-46.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-47.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-48.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-49.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-5.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-50.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-51.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-52.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-53.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-54.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-55.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-56.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-57.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-58.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-59.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-6.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-60.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-61.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-62.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-63.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-7.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-8.png -------------------------------------------------------------------------------- /docs/reference/plot.bayesTest-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plot.bayesTest-9.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-10.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-11.png -------------------------------------------------------------------------------- /docs/reference/plotInvGamma-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotInvGamma-12.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-1.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-10.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-11.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-12.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-2.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-3.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-4.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-5.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-6.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-7.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-8.png -------------------------------------------------------------------------------- /docs/reference/plotLogNormal-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotLogNormal-9.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/bern-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/bern-1.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/bern-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/bern-2.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/bern-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/bern-3.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/bern-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/bern-4.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/bern-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/bern-5.png -------------------------------------------------------------------------------- /docs/reference/plotNormalInvGamma-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/reference/plotNormalInvGamma-1.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/bern-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/bern-1.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/bern-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/bern-2.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/bern-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/bern-3.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/bern-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/bern-4.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/bern-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/bern-5.png -------------------------------------------------------------------------------- /vignettes/extra/priors_blog/strong_priors-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/vignettes/extra/priors_blog/strong_priors-1.png -------------------------------------------------------------------------------- /docs/articles/extra/priors_blog/strong_priors-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/extra/priors_blog/strong_priors-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-2-2.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-4-2.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-4-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-4-3.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-6-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-6-2.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-6-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-6-3.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/introduction_files/figure-html/unnamed-chunk-8-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankPortman/bayesAB/HEAD/docs/articles/introduction_files/figure-html/unnamed-chunk-8-2.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^cran-comments.md$ 5 | ^codecov\.yml$ 6 | ^todo$ 7 | ^docs$ 8 | ^_pkgdown\.yml$ 9 | ^pkgdown$ 10 | ^CRAN-RELEASE$ 11 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.7.3 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: 5 | extra/priors: priors.html 6 | introduction: introduction.html 7 | last_built: 2021-06-24T20:22Z 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | src/*.o 5 | src/*.so 6 | src/*.dll 7 | *~ 8 | tests/testthat/*.pdf 9 | inst/doc 10 | vignettes/*.html 11 | todo 12 | R/flow.R 13 | R/checks2.R 14 | docs 15 | -------------------------------------------------------------------------------- /src/init.cpp: -------------------------------------------------------------------------------- 1 | // RegisteringDynamic Symbols 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void R_init_bayesAB(DllInfo* info) { 8 | R_registerRoutines(info, NULL, NULL, NULL, NULL); 9 | R_useDynamicSymbols(info, TRUE); 10 | } 11 | -------------------------------------------------------------------------------- /tests/testthat/test-util.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('util') 3 | 4 | test_that("Success", { 5 | 6 | expect_silent(ppareto(5, 4, 3)) 7 | expect_equal(removeGenericArgs(c('A_data')), character(0)) 8 | expect_equal(removeGenericArgs(c('A_data', 'hi')), 'hi') 9 | 10 | }) 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | cache: packages 3 | warnings_are_errors: false 4 | 5 | before_install: 6 | - tlmgr install ucs 7 | - sudo apt-get -y install libsodium-dev 8 | 9 | r_packages: 10 | - covr 11 | - plumber 12 | 13 | after_success: 14 | - Rscript -e 'covr::codecov(line_exclusions = list("R/bandit.R", "src/init.cpp", "R/plotDists.R" = 80:106, "R/makePlots.R" = 43:95, "R/dists.R" = 42:48))' 15 | -------------------------------------------------------------------------------- /bayesAB.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Version 1.1.3 Submission 2 | Minor release for fixing a deprecation warning caused by latest release of ggplot2. No API changes. 3 | 4 | ## Test environments 5 | - local OS X install, R 4.0.3 6 | - ubuntu 14.04 (on travis-ci), R 4.0.3 7 | - win-builder (devel and release) 8 | 9 | ## R CMD check results 10 | There were no ERRORs,WARNINGs, or NOTEs. 11 | 12 | ## Dependencies 13 | There are currently no dependencies for this package. 14 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | PoissonClosed_ <- function(alpha_1, beta_1, alpha_2, beta_2) { 5 | .Call('_bayesAB_PoissonClosed_', PACKAGE = 'bayesAB', alpha_1, beta_1, alpha_2, beta_2) 6 | } 7 | 8 | BernoulliClosed_ <- function(alpha_1, beta_1, alpha_2, beta_2) { 9 | .Call('_bayesAB_BernoulliClosed_', PACKAGE = 'bayesAB', alpha_1, beta_1, alpha_2, beta_2) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /man/rename.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/combine.R 3 | \name{rename} 4 | \alias{rename} 5 | \title{Rename the posterior for a bayesTest object} 6 | \usage{ 7 | rename(bT, newName) 8 | } 9 | \arguments{ 10 | \item{bT}{a bayesTest object} 11 | 12 | \item{newName}{the new name you want for the posterior param (string)} 13 | } 14 | \value{ 15 | a \code{bayesTest} object with the posterior parameter renamed 16 | } 17 | \description{ 18 | Rename the posterior param for a bayesTest object. 19 | } 20 | \seealso{ 21 | \code{\link{combine}} 22 | } 23 | -------------------------------------------------------------------------------- /man/grab.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/combine.R 3 | \name{grab} 4 | \alias{grab} 5 | \title{Grab the supplied posterior from a bayesTest object} 6 | \usage{ 7 | grab(bT, posterior) 8 | } 9 | \arguments{ 10 | \item{bT}{a bayesTest object} 11 | 12 | \item{posterior}{the name of a posterior in that object (string)} 13 | } 14 | \value{ 15 | a \code{bayesTest} object with the posterior parameter isolated 16 | } 17 | \description{ 18 | Grab the supplied posterior from a bayesTest object, returning another bayesTest object. 19 | } 20 | \seealso{ 21 | \code{\link{combine}} 22 | } 23 | -------------------------------------------------------------------------------- /R/dist-normal.R: -------------------------------------------------------------------------------- 1 | drawMusAndSigmas <- function(data, 2 | mu, 3 | lambda, 4 | alpha, 5 | beta, 6 | n_samples) { 7 | 8 | n <- length(data) 9 | xbar <- mean(data) 10 | 11 | ss <- var(data) * (n - 1) 12 | 13 | new_mu <- lambda * mu + n * xbar 14 | new_mu <- new_mu / (lambda + n) 15 | 16 | new_lambda <- lambda + n 17 | 18 | new_alpha <- alpha + n / 2 19 | 20 | new_beta <- beta + .5 * (ss + (n * lambda) / (lambda + n) * (xbar - mu) ^ 2) 21 | 22 | rNormalInverseGamma(n_samples, new_mu, new_lambda, new_alpha, new_beta) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/plotPoisson.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotPoisson} 4 | \alias{plotPoisson} 5 | \title{Plot the PDF of the Poisson distribution.} 6 | \usage{ 7 | plotPoisson(lambda) 8 | } 9 | \arguments{ 10 | \item{lambda}{\eqn{\lambda} parameter of the Poisson distribution.} 11 | } 12 | \value{ 13 | The PDF of Poisson(\eqn{\lambda}). 14 | } 15 | \description{ 16 | Plot the PDF of the Poisson distribution. 17 | } 18 | \note{ 19 | The output can be treated like any \code{ggplot2} object and modified accordingly. 20 | } 21 | \examples{ 22 | plotPoisson(1) 23 | plotPoisson(5) 24 | \dontrun{plotPoisson(5) + ggtitle('I hate the default title!')} 25 | } 26 | -------------------------------------------------------------------------------- /man/plotPareto.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotPareto} 4 | \alias{plotPareto} 5 | \title{Plot the PDF of the Pareto distribution.} 6 | \usage{ 7 | plotPareto(xm, alpha) 8 | } 9 | \arguments{ 10 | \item{xm}{xm parameter of the Pareto distribution.} 11 | 12 | \item{alpha}{alpha parameter of the Pareto distribution.} 13 | } 14 | \value{ 15 | The PDF of Pareto(xm, alpha). 16 | } 17 | \description{ 18 | Plot the PDF of the Pareto distribution. 19 | } 20 | \note{ 21 | The output can be treated like any \code{ggplot2} object and modified accordingly. 22 | } 23 | \examples{ 24 | plotPareto(1, 1) 25 | plotPareto(5, 3) 26 | \dontrun{plotPareto(5, 3) + ggtitle('I hate the default title!')} 27 | } 28 | -------------------------------------------------------------------------------- /man/plotBeta.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotBeta} 4 | \alias{plotBeta} 5 | \title{Plot the PDF of the Beta distribution.} 6 | \usage{ 7 | plotBeta(alpha, beta) 8 | } 9 | \arguments{ 10 | \item{alpha}{\eqn{\alpha} parameter of the Beta distribution.} 11 | 12 | \item{beta}{\eqn{\beta} parameter of the Beta distribution.} 13 | } 14 | \value{ 15 | The PDF of Beta(\eqn{\alpha}, \eqn{\beta}). 16 | } 17 | \description{ 18 | Plot the PDF of the Beta distribution. 19 | } 20 | \note{ 21 | The output can be treated like any \code{ggplot2} object and modified accordingly. 22 | } 23 | \examples{ 24 | plotBeta(1, 1) 25 | plotBeta(2, 5) 26 | \dontrun{plotBeta(2, 5) + ggtitle('I hate the default title!')} 27 | } 28 | -------------------------------------------------------------------------------- /man/plotNormal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotNormal} 4 | \alias{plotNormal} 5 | \title{Plot the PDF of the Normal distribution.} 6 | \usage{ 7 | plotNormal(mu, sd) 8 | } 9 | \arguments{ 10 | \item{mu}{\eqn{\mu} parameter of the Normal distribution.} 11 | 12 | \item{sd}{\eqn{\sigma} parameter of the Normal distribution.} 13 | } 14 | \value{ 15 | The PDF of Normal(\eqn{\mu}, \eqn{\sigma^2}). 16 | } 17 | \description{ 18 | Plot the PDF of the Normal distribution. 19 | } 20 | \note{ 21 | The output can be treated like any \code{ggplot2} object and modified accordingly. 22 | } 23 | \examples{ 24 | plotNormal(1, 1) 25 | plotNormal(2, 5) 26 | \dontrun{plotNormal(2, 5) + ggtitle('I hate the default title!')} 27 | } 28 | -------------------------------------------------------------------------------- /tests/testthat/test-bandit.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bandit') 3 | 4 | A_binom <- rbinom(100, 1, .5) 5 | B_binom <- rbinom(100, 1, .6) 6 | 7 | AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 8 | 9 | bandit <- banditize(AB1, "Probability") 10 | 11 | test_that("Error", { 12 | 13 | expect_error(banditize(AB1 + AB1), "Can't turn arbitrary combined distribution into a Bayesian Bandit.", 14 | fixed = TRUE) 15 | 16 | }) 17 | 18 | test_that("Success", { 19 | 20 | expect_true(bandit$serveRecipe() %in% c('A', 'B')) 21 | expect_silent(bandit$getBayesTest()) 22 | expect_silent(bandit$getOriginalTest()) 23 | expect_equal(bandit$setResults(list('A' = 1)), 0) 24 | expect_output(print(bandit), "updates") 25 | 26 | }) 27 | -------------------------------------------------------------------------------- /man/plotLogNormal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotLogNormal} 4 | \alias{plotLogNormal} 5 | \title{Plot the PDF of the Log Normal distribution.} 6 | \usage{ 7 | plotLogNormal(mu, sigma) 8 | } 9 | \arguments{ 10 | \item{mu}{\eqn{\mu} parameter of the Log Normal distribution.} 11 | 12 | \item{sigma}{\eqn{\sigma} parameter of the Log Normal distribution.} 13 | } 14 | \value{ 15 | The PDF of Log Normal(\eqn{\mu}, \eqn{\sigma^2}). 16 | } 17 | \description{ 18 | Plot the PDF of the Log Normal distribution. 19 | } 20 | \note{ 21 | The output can be treated like any \code{ggplot2} object and modified accordingly. 22 | } 23 | \examples{ 24 | plotLogNormal(1, 1) 25 | plotLogNormal(2, .5) 26 | \dontrun{plotLogNormal(2, .5) + ggtitle('I hate the default title!')} 27 | } 28 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: bayesAB 2 | Type: Package 3 | Title: Fast Bayesian Methods for AB Testing 4 | Version: 1.1.3 5 | Date: 2021-06-24 6 | Authors@R: person("Frank", "Portman", email = "frank1214@gmail.com", role = c("aut", "cre")) 7 | Description: A suite of functions that allow the user to analyze A/B test 8 | data in a Bayesian framework. Intended to be a drop-in replacement for 9 | common frequentist hypothesis test such as the t-test and chi-sq test. 10 | License: MIT + file LICENSE 11 | Imports: 12 | Rcpp (>= 0.12.4), 13 | ggplot2 (>= 3.2.0), 14 | methods, 15 | rlang (>= 0.4.0) 16 | LinkingTo: Rcpp 17 | RoxygenNote: 7.1.1 18 | Encoding: UTF-8 19 | URL: https://github.com/FrankPortman/bayesAB 20 | BugReports: https://github.com/FrankPortman/bayesAB/issues 21 | Suggests: 22 | testthat, 23 | knitr, 24 | rmarkdown, 25 | magrittr, 26 | plumber (>= 0.3.0) 27 | VignetteBuilder: knitr 28 | -------------------------------------------------------------------------------- /man/plotGamma.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotGamma} 4 | \alias{plotGamma} 5 | \title{Plot the PDF of the Gamma distribution.} 6 | \usage{ 7 | plotGamma(shape, rate) 8 | } 9 | \arguments{ 10 | \item{shape}{shape (\eqn{\alpha}) parameter of the Gamma distribution.} 11 | 12 | \item{rate}{rate (\eqn{\beta}) parameter of the Gamma distribution.} 13 | } 14 | \value{ 15 | The PDF of Gamma(shape, rate). 16 | } 17 | \description{ 18 | Plot the PDF of the Gamma distribution. 19 | } 20 | \details{ 21 | Note: We use the shape/rate parametrization of Gamma. See https://en.wikipedia.org/wiki/Gamma_distribution for details. 22 | } 23 | \note{ 24 | The output can be treated like any \code{ggplot2} object and modified accordingly. 25 | } 26 | \examples{ 27 | plotGamma(1, 1) 28 | plotGamma(2, 5) 29 | \dontrun{plotGamma(2, 5) + ggtitle('I hate the default title!')} 30 | } 31 | -------------------------------------------------------------------------------- /R/util.R: -------------------------------------------------------------------------------- 1 | getProb <- function(vals, percent_lift = 0) { 2 | mean((100 * vals > percent_lift)) 3 | } 4 | 5 | getCredInt <- function(vals, prop = .9) { 6 | crit <- (1 - prop) / 2 7 | quantile(vals, c(crit, 1 - crit)) 8 | } 9 | 10 | getLift <- function(A_samples, B_samples) { 11 | (A_samples - B_samples) / B_samples 12 | } 13 | 14 | coalesce <- function(n) ifelse(is.na(n) | is.nan(n), 0, n) 15 | 16 | # Expected loss from switching from B to A 17 | getPostError <- function(A_samples, B_samples, f = function(a, b) (a-b)/b) { 18 | BoverA <- B_samples > A_samples 19 | loss <- f(B_samples, A_samples) 20 | coalesce(mean(BoverA) * mean(loss[BoverA])) 21 | } 22 | 23 | isClosed <- function(distribution) grepl("C", distribution) 24 | 25 | removeGenericArgs <- function(vec) { 26 | vec[!vec %in% c('A_data', 'B_data', 'n_samples')] 27 | } 28 | 29 | funcLooper <- function(inputs, funcs) { 30 | for(func in funcs) do.call(func, inputs) 31 | } 32 | 33 | getDistPlotFunc <- function(dist) { 34 | eval(parse(text = paste0('plot', dist))) 35 | } 36 | -------------------------------------------------------------------------------- /man/c.bayesTest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{c.bayesTest} 4 | \alias{c.bayesTest} 5 | \title{Concatenate bayesTest objects} 6 | \usage{ 7 | \method{c}{bayesTest}(..., errorCheck = TRUE) 8 | } 9 | \arguments{ 10 | \item{...}{\code{bayesTest} objects} 11 | 12 | \item{errorCheck}{check that objects can be concatenated? Setting this to \code{FALSE} can have unintended 13 | effects if the \code{bayesTest} objects have different params but can have some speedups 14 | if you are sure the objects are of the same type.} 15 | } 16 | \value{ 17 | A \code{bayesTest} object with concatenated posteriors. 18 | } 19 | \description{ 20 | Concatenate method for objects of class "bayesTest". 21 | } 22 | \examples{ 23 | A_pois <- rpois(100, 5) 24 | B_pois <- rpois(100, 4.7) 25 | 26 | AB1 <- bayesTest(A_pois, B_pois, priors = c('shape' = 25, 'rate' = 5), distribution = 'poisson') 27 | AB2 <- bayesTest(A_pois, B_pois, priors = c('shape' = 25, 'rate' = 5), distribution = 'poisson') 28 | c(AB1, AB2) 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/closedTests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace Rcpp; 3 | 4 | double lbeta(double a, double b) { 5 | return lgamma(a) + lgamma(b) - lgamma(a + b); 6 | } 7 | 8 | // [[Rcpp::export]] 9 | double PoissonClosed_(double alpha_1, double beta_1, double alpha_2, double beta_2) { 10 | double total = 0; 11 | for(int i = 0; i < alpha_1; i++) { 12 | double lt = i * log(beta_1) + 13 | alpha_2 * log(beta_2) - 14 | (i + alpha_2) * log(beta_1 + beta_2) - 15 | log(i + alpha_2) - 16 | lbeta(i + 1, alpha_2); 17 | total += exp(lt); 18 | } 19 | return total; 20 | } 21 | 22 | // [[Rcpp::export]] 23 | double BernoulliClosed_(double alpha_1, double beta_1, double alpha_2, double beta_2) { 24 | double total = 0; 25 | for(int i = 0; i < alpha_2; i++) { 26 | double lt = lbeta(alpha_1 + i, beta_1 + beta_2) - 27 | log(beta_2 + i) - 28 | lbeta(1 + i, beta_2) - 29 | lbeta(alpha_1, beta_1); 30 | total += exp(lt); 31 | } 32 | return 1 - total; 33 | } 34 | -------------------------------------------------------------------------------- /R/checks.R: -------------------------------------------------------------------------------- 1 | checkNumericData <- function(A_data, B_data) stopifnot(is.numeric(A_data), is.numeric(B_data)) 2 | checkCompleteData <- function(A_data, B_data) stopifnot(!is.na(A_data), !is.na(B_data)) 3 | checkNumericPriors <- function(...) { 4 | priors <- c(...) 5 | if(!is.numeric(priors)) stop("One or more priors aren't numeric.") 6 | } 7 | 8 | checkPositiveData <- function(A_data, B_data) stopifnot(A_data >= 0, B_data >= 0) 9 | checkNotZeroData <- function(A_data, B_data) stopifnot(A_data != 0, B_data != 0) 10 | checkBinomialData <- function(A_data, B_data) stopifnot(A_data %in% c(0, 1), B_data %in% c(0, 1)) 11 | checkIntegerData <- function(A_data, B_data) stopifnot(as.integer(A_data) == A_data, as.integer(B_data) == B_data) 12 | 13 | checkGammaPriors <- function(shape, rate, ...) stopifnot(shape > 0, rate > 0) 14 | checkBetaPriors <- function(alpha, beta, ...) stopifnot(alpha > 0, beta > 0) 15 | checkParetoPriors <- function(xm, alpha, ...) stopifnot(xm > 0, alpha > 0) 16 | checkNormalInvGammaPriors <- function(mu, lambda, alpha, beta) stopifnot(lambda > 0, alpha > 0, beta > 0) 17 | -------------------------------------------------------------------------------- /man/plotInvGamma.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotInvGamma} 4 | \alias{plotInvGamma} 5 | \title{Plot the PDF of the Inverse Gamma distribution.} 6 | \usage{ 7 | plotInvGamma(shape, scale) 8 | } 9 | \arguments{ 10 | \item{shape}{shape parameter of the Inverse Gamma distribution.} 11 | 12 | \item{scale}{scale parameter of the Inverse Gamma distribution.} 13 | } 14 | \value{ 15 | The PDF of InvGamma(shape, scale). 16 | } 17 | \description{ 18 | Plot the PDF of the Inverse Gamma distribution. 19 | } 20 | \note{ 21 | The output can be treated like any \code{ggplot2} object and modified accordingly. 22 | Also note that the \code{scale} parameter of the Inverse Gamma distribution is 23 | analogous to the \code{beta} (or rate) parameter of the regular Gamma distribution. 24 | The \code{beta} parameter of the \link{plotNormalInvGamma} distribution is analogous 25 | to the \code{scale} parameter here. 26 | } 27 | \examples{ 28 | plotInvGamma(2, 4) 29 | plotInvGamma(1, 17) 30 | \dontrun{plotInvGamma(1, 17) + ggtitle('I hate the default title!')} 31 | } 32 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | reference: 2 | - title: "Running a Bayesian AB Test" 3 | desc: > 4 | Construct a Bayesian AB Test object from some data 5 | and priors. 6 | contents: 7 | - bayesTest 8 | - title: "Plotting Distributions" 9 | desc: > 10 | Functions for plotting distributions. Useful for 11 | experimenting with data and choosing priors for your 12 | bayesTest objects. 13 | contents: 14 | - plotBeta 15 | - plotGamma 16 | - plotInvGamma 17 | - plotLogNormal 18 | - plotNormal 19 | - plotPareto 20 | - plotPoisson 21 | - plotNormalInvGamma 22 | - title: "Generics" 23 | desc: > 24 | Generic functions that can help you examine a trained 25 | bayesTest object. 26 | contents: 27 | - plot.bayesTest 28 | - summary.bayesTest 29 | - c.bayesTest 30 | - title: "Helpers" 31 | desc: > 32 | Helper functions for further exploring a trained 33 | bayesTest object. 34 | contents: 35 | - grab 36 | - rename 37 | - combine 38 | - title: "Deploying" 39 | desc: > 40 | Functions to construct and deploy a Bayesian Bandit 41 | from a bayesTest object. 42 | contents: 43 | - banditize 44 | - deployBandit 45 | -------------------------------------------------------------------------------- /man/deployBandit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bandit.R 3 | \name{deployBandit} 4 | \alias{deployBandit} 5 | \title{Deploy a bayesBandit object as a JSON API.} 6 | \usage{ 7 | deployBandit(bandit, port = 8000) 8 | } 9 | \arguments{ 10 | \item{bandit}{a bayesBandit object} 11 | 12 | \item{port}{port to deploy on} 13 | } 14 | \value{ 15 | An active \code{http} process on some port. 16 | } 17 | \description{ 18 | Turn your bayesBandit object into an API and serve/update requests through HTTP. 19 | } 20 | \details{ 21 | \code{deployBandit} turns a Bayesian bandit into a JSON API that accepts curl requests. Two of the five methods of 22 | bayesBandit classes are exposed: \code{serveRecipe} and \code{setResults}. Assuming the API is deployed on \code{localhost} this is an 23 | example of how it would be hit: 24 | 25 | \deqn{curl http://localhost:8000/serveRecipe} 26 | 27 | \deqn{curl --data '{"A":[1, 0, 1, 1], "B":[0, 0, 0, 1]}' http://localhost:8000/setResults} 28 | } 29 | \examples{ 30 | A_binom <- rbinom(100, 1, .5) 31 | B_binom <- rbinom(100, 1, .6) 32 | 33 | AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 34 | 35 | binomialBandit <- banditize(AB1) 36 | \dontrun{deployBandit(binomialBandit)} 37 | 38 | } 39 | -------------------------------------------------------------------------------- /man/plotNormalInvGamma.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \name{plotNormalInvGamma} 4 | \alias{plotNormalInvGamma} 5 | \title{Plot the bivariate PDF of the Normal Inverse Gamma Distribution.} 6 | \usage{ 7 | plotNormalInvGamma(mu, lambda, alpha, beta) 8 | } 9 | \arguments{ 10 | \item{mu}{\eqn{\mu} parameter of the Normal Inverse Gamma distribution.} 11 | 12 | \item{lambda}{\eqn{\lambda} parameter of the Normal Inverse Gamma distribution.} 13 | 14 | \item{alpha}{\eqn{\alpha} parameter of the Normal Inverse Gamma distribution.} 15 | 16 | \item{beta}{\eqn{\beta} parameter of the Normal Inverse Gamma distribution.} 17 | } 18 | \value{ 19 | The PDF of NormalInverseGamma(mu, lambda, alpha, beta) 20 | } 21 | \description{ 22 | Plot the bivariate PDF of the Normal Inverse Gamma Distribution. 23 | } 24 | \note{ 25 | This is a bivariate distribution (commonly used to model mean and 26 | variance of the normal distribution) and returns a 2d contour 27 | plot instead of a typical one dimensional PDF. You may want to experiment 28 | with both this distribution and the \code{plotNormal} and \code{plotInvGamma} 29 | outputs separately before arriving at a suitable set of priors for the 30 | Normal and LogNormal \code{bayesTest}. 31 | } 32 | \examples{ 33 | plotNormalInvGamma(3, 1, 1, 1) 34 | } 35 | -------------------------------------------------------------------------------- /tests/testthat/test-dists.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('dists') 3 | 4 | dummyDist <- plotDist('norm', 'Normal', c('mu', 'sd')) 5 | dummyDist2 <- plotDist('norm', 'Normal', c('mu', 'sd')) 6 | 7 | test_that("Failures based on inputs", { 8 | 9 | expect_error(dinvgamma(5, -1, 5), "Shape or scale parameter negative") 10 | 11 | }) 12 | 13 | test_that("Closure madness", { 14 | 15 | expect_equal(dummyDist, dummyDist2) 16 | expect_identical(environment(dummyDist)$distArgs, environment(dummyDist2)$distArgs) 17 | expect_equal(environment(dummyDist)$name, 'Normal') 18 | expect_equal(formals(dummyDist), as.pairlist(alist(mu =, sd =))) 19 | }) 20 | 21 | test_that("Success", { 22 | 23 | expect_equal(plotPoisson(1)$labels$y, 'PDF') 24 | expect_equal(plotPareto(1, 1)$labels$y, 'PDF') 25 | expect_equal(plotNormal(1, 1)$labels$y, 'PDF') 26 | expect_equal(plotGamma(1, 1)$labels$y, 'PDF') 27 | expect_equal(plotBeta(1, 1)$labels$y, 'PDF') 28 | expect_equal(plotInvGamma(1, 1)$labels$y, 'PDF') 29 | expect_equal(plotLogNormal(1, 1)$labels$y, 'PDF') 30 | expect_equal(qinvgamma(1 - (.Machine$double.eps) / 2, 2, 2), Inf) 31 | expect_equal(dpareto(c(0, 1, 2), 1, 1), c(0, 0, .25)) 32 | expect_equal(dpareto(c(5, 15), 20, 3), c(0, 0)) 33 | expect_equal(max(plotNormalInvGamma(3, 100, 51, 216)$data$sig_sq), qgamma(.99, 51, 216) * 100) 34 | expect_equal(plotNormalInvGamma(3, 1, 1, 1)$labels$y, 'sig_sq') 35 | 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test-uniform.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesUniformTest') 3 | 4 | A_data <- runif(100, max = 20) 5 | B_data <- runif(100, max = 15) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('xm' = 17, 'alpha' = 5) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'uniform'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'uniform'), 19 | "Misnamed priors provided for supplied distribution.") 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'alpha' = -3), distribution = 'uniform'), 22 | "alpha > 0 is not TRUE", fixed = TRUE) 23 | 24 | expect_error(bayesTest(c(A_data, -1), B_data, priors = priors, distribution = 'uniform'), 25 | "A_data >= 0 are not all TRUE", fixed = TRUE) 26 | 27 | }) 28 | 29 | test_that("Success", { 30 | 31 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'uniform') 32 | 33 | expect_is(successfulTest, "bayesTest") 34 | 35 | expect_output(str(successfulTest), "List of 5") # inputs 36 | expect_output(str(successfulTest), "List of 2") # outer 37 | 38 | }) 39 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method("*",bayesTest) 4 | S3method("+",bayesTest) 5 | S3method("-",bayesTest) 6 | S3method("/",bayesTest) 7 | S3method(c,bayesTest) 8 | S3method(plot,bayesTest) 9 | S3method(plot,bayesTestClosed) 10 | S3method(print,bayesBandit) 11 | S3method(print,bayesTest) 12 | S3method(print,bayesTestClosed) 13 | S3method(print,plotBayesTest) 14 | S3method(print,summaryBayesTest) 15 | S3method(print,summaryBayesTestClosed) 16 | S3method(summary,bayesTest) 17 | S3method(summary,bayesTestClosed) 18 | export(banditize) 19 | export(bayesTest) 20 | export(combine) 21 | export(deployBandit) 22 | export(grab) 23 | export(plotBeta) 24 | export(plotGamma) 25 | export(plotInvGamma) 26 | export(plotLogNormal) 27 | export(plotNormal) 28 | export(plotNormalInvGamma) 29 | export(plotPareto) 30 | export(plotPoisson) 31 | export(rename) 32 | importFrom(Rcpp,evalCpp) 33 | importFrom(graphics,par) 34 | importFrom(methods,is) 35 | importFrom(rlang,.data) 36 | importFrom(stats,dbeta) 37 | importFrom(stats,dgamma) 38 | importFrom(stats,dlnorm) 39 | importFrom(stats,dnorm) 40 | importFrom(stats,dpois) 41 | importFrom(stats,pnorm) 42 | importFrom(stats,qgamma) 43 | importFrom(stats,qlnorm) 44 | importFrom(stats,qpois) 45 | importFrom(stats,quantile) 46 | importFrom(stats,rbeta) 47 | importFrom(stats,rgamma) 48 | importFrom(stats,rnorm) 49 | importFrom(stats,runif) 50 | importFrom(stats,var) 51 | importFrom(utils,head) 52 | importFrom(utils,packageVersion) 53 | importFrom(utils,tail) 54 | useDynLib(bayesAB) 55 | -------------------------------------------------------------------------------- /man/plotDistributions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotDists.R 3 | \docType{data} 4 | \name{plotDistributions} 5 | \alias{plotDistributions} 6 | \title{Plot distributions to explore data and/or choose priors.} 7 | \description{ 8 | These are helper functions to help explore data and/or choose priors. Click further for more details. 9 | 10 | \itemize{ 11 | \item \link{plotBeta} 12 | \item \link{plotGamma} 13 | \item \link{plotInvGamma} 14 | \item \link{plotLogNormal} 15 | \item \link{plotNormal} 16 | \item \link{plotPareto} 17 | \item \link{plotPoisson} 18 | } 19 | } 20 | \note{ 21 | Choosing priors correctly is very important. Please see http://fportman.com/writing/bayesab-0-dot-7-0-plus-a-primer-on-priors/ for a detailed example of choosing priors 22 | within bayesAB. Here are some ways to leverage objective/diffuse (assigning equal probability to all values) priors: 23 | 24 | \itemize{\item \code{Beta}(1, 1) 25 | \item \code{Gamma}(eps, eps) ~ \code{Gamma}(.00005, .00005) will be effectively diffuse 26 | \item \code{InvGamma}(eps, eps) ~ \code{InvGamma}(.00005, .00005) will be effectively diffuse 27 | \item \code{Pareto}(eps, eps) ~ \code{Pareto}(.005, .005) will be effectively diffuse} 28 | 29 | Keep in mind that the Prior Plots for bayesTest's run with diffuse priors may not plot correctly as they will not be truncated as they 30 | approach infinity. See \link{plot.bayesTest} for how to turn off the Prior Plots. 31 | 32 | plot{...} functions are generated programmatically so the function calls in 33 | their \code{body} will be substituted directly 34 | } 35 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | // PoissonClosed_ 9 | double PoissonClosed_(double alpha_1, double beta_1, double alpha_2, double beta_2); 10 | RcppExport SEXP _bayesAB_PoissonClosed_(SEXP alpha_1SEXP, SEXP beta_1SEXP, SEXP alpha_2SEXP, SEXP beta_2SEXP) { 11 | BEGIN_RCPP 12 | Rcpp::RObject rcpp_result_gen; 13 | Rcpp::RNGScope rcpp_rngScope_gen; 14 | Rcpp::traits::input_parameter< double >::type alpha_1(alpha_1SEXP); 15 | Rcpp::traits::input_parameter< double >::type beta_1(beta_1SEXP); 16 | Rcpp::traits::input_parameter< double >::type alpha_2(alpha_2SEXP); 17 | Rcpp::traits::input_parameter< double >::type beta_2(beta_2SEXP); 18 | rcpp_result_gen = Rcpp::wrap(PoissonClosed_(alpha_1, beta_1, alpha_2, beta_2)); 19 | return rcpp_result_gen; 20 | END_RCPP 21 | } 22 | // BernoulliClosed_ 23 | double BernoulliClosed_(double alpha_1, double beta_1, double alpha_2, double beta_2); 24 | RcppExport SEXP _bayesAB_BernoulliClosed_(SEXP alpha_1SEXP, SEXP beta_1SEXP, SEXP alpha_2SEXP, SEXP beta_2SEXP) { 25 | BEGIN_RCPP 26 | Rcpp::RObject rcpp_result_gen; 27 | Rcpp::RNGScope rcpp_rngScope_gen; 28 | Rcpp::traits::input_parameter< double >::type alpha_1(alpha_1SEXP); 29 | Rcpp::traits::input_parameter< double >::type beta_1(beta_1SEXP); 30 | Rcpp::traits::input_parameter< double >::type alpha_2(alpha_2SEXP); 31 | Rcpp::traits::input_parameter< double >::type beta_2(beta_2SEXP); 32 | rcpp_result_gen = Rcpp::wrap(BernoulliClosed_(alpha_1, beta_1, alpha_2, beta_2)); 33 | return rcpp_result_gen; 34 | END_RCPP 35 | } 36 | -------------------------------------------------------------------------------- /tests/testthat/test-exponential.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesExponentialTest') 3 | 4 | A_data <- rexp(100) 5 | B_data <- rexp(100) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('shape' = 3, 'rate' = 5) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'exponential'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(c(A_data, -3), B_data, priors = priors, distribution = 'exponential'), 19 | "A_data >= 0 are not all TRUE", fixed = TRUE) 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'exponential'), 22 | "Misnamed priors provided for supplied distribution.") 23 | 24 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = 'cabbage'), distribution = 'exponential'), 25 | "One or more priors aren't numeric.") 26 | 27 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = -3), distribution = 'exponential'), 28 | "shape > 0 is not TRUE", fixed = TRUE) 29 | 30 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'rate' = -3), distribution = 'exponential'), 31 | "rate > 0 is not TRUE", fixed = TRUE) 32 | 33 | }) 34 | 35 | test_that("Success", { 36 | 37 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'exponential') 38 | 39 | expect_is(successfulTest, "bayesTest") 40 | 41 | expect_output(str(successfulTest), "List of 2") 42 | expect_output(str(successfulTest), "List of 5") 43 | 44 | }) 45 | -------------------------------------------------------------------------------- /tests/testthat/test-poisson.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesPoissonTest') 3 | 4 | A_data <- rpois(100, 5) 5 | B_data <- rpois(100, 4) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('shape' = 5, 'rate' = 3) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'poisson'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(c(A_data, 3.5), B_data, priors = priors, distribution = 'poisson'), 19 | "as.integer(A_data) == A_data are not all TRUE", fixed = TRUE) 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'poisson'), 22 | "Misnamed priors provided for supplied distribution.") 23 | 24 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = 'cabbage'), distribution = 'poisson'), 25 | "One or more priors aren't numeric.") 26 | 27 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = -3), distribution = 'poisson'), 28 | "shape > 0 is not TRUE", fixed = TRUE) 29 | 30 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'rate' = -3), distribution = 'poisson'), 31 | "rate > 0 is not TRUE", fixed = TRUE) 32 | 33 | }) 34 | 35 | test_that("Success", { 36 | 37 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'poisson') 38 | 39 | expect_is(successfulTest, "bayesTest") 40 | 41 | expect_output(str(successfulTest), "List of 5") # inputs 42 | expect_output(str(successfulTest), "List of 2") # outer 43 | 44 | }) 45 | -------------------------------------------------------------------------------- /tests/testthat/test-normal.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesNormalTest') 3 | 4 | A_data <- rnorm(100) 5 | B_data <- rnorm(100) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('mu' = 5, 'lambda' = 3, 'alpha' = 3, 'beta' = 2) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'normal'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(A_data_bad_string, B_data, priors = priors, distribution = 'normal'), 19 | "is.numeric(A_data) is not TRUE", fixed = TRUE) 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'normal'), 22 | "Misnamed priors provided for supplied distribution.") 23 | 24 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'lambda' = -3), distribution = 'normal'), 25 | "lambda > 0 is not TRUE", fixed = TRUE) 26 | 27 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-3], 'alpha' = -3), distribution = 'normal'), 28 | "alpha > 0 is not TRUE", fixed = TRUE) 29 | 30 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-4], 'beta' = -3), distribution = 'normal'), 31 | "beta > 0 is not TRUE", fixed = TRUE) 32 | 33 | }) 34 | 35 | test_that("Success", { 36 | 37 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'normal') 38 | 39 | expect_is(successfulTest, "bayesTest") 40 | 41 | expect_output(str(successfulTest), "List of 5") 42 | expect_output(str(successfulTest), "List of 2") 43 | expect_output(str(successfulTest), "List of 3") 44 | 45 | }) 46 | -------------------------------------------------------------------------------- /R/dists.R: -------------------------------------------------------------------------------- 1 | dpareto <- function(x, xm, alpha) ifelse(x > xm , alpha * xm ** alpha / (x ** (alpha + 1)), 0) 2 | ppareto <- function(q, xm, alpha) ifelse(q > xm , 1 - (xm / q) ** alpha, 0 ) 3 | qpareto <- function(p, xm, alpha) ifelse(p < 0 | p > 1, NaN, xm * (1 - p) ** (-1 / alpha)) 4 | rpareto <- function(n, xm, alpha) qpareto(runif(n), xm, alpha) 5 | 6 | qinvgamma_ <- function(area, shape, scale) { 7 | if((1 - area) <= .Machine$double.eps) { 8 | return(Inf) 9 | } 10 | if(area <= .Machine$double.eps) { 11 | return(0) 12 | } 13 | return(1 / qgamma(1 - area, shape, scale)) 14 | } 15 | 16 | qinvgamma <- Vectorize(qinvgamma_, vectorize.args = 'area') 17 | 18 | dinvgamma_ <- function(x, shape, scale) { 19 | if (shape <= 0 | scale <= 0) { 20 | stop("Shape or scale parameter negative in dinvgamma().\n") 21 | } 22 | if(x == 0) return(0) 23 | log.density <- shape * log(scale) - lgamma(shape) - (shape + 1) * log(x) - (scale / x) 24 | return(exp(log.density)) 25 | } 26 | 27 | dinvgamma <- Vectorize(dinvgamma_, vectorize.args = 'x') 28 | 29 | dNormalInverseGamma <- function(x, sig_sq, mu, lambda, alpha, beta) { 30 | sqrt(lambda) / (sqrt(sig_sq) * 31 | sqrt(2 * pi)) * (beta ^ alpha) / gamma(alpha) * 32 | (1 / sig_sq) ^ (alpha + 1) * 33 | exp(-1 * (2 * beta + lambda * (x - mu) ^ 2) / (2 * sig_sq) ) 34 | } 35 | 36 | rNormalInverseGamma <- function(n, mu, lambda, alpha, beta) { 37 | sig_sq <- 1 / rgamma(n, alpha, beta) 38 | mu <- rnorm(n, mu, sqrt(sig_sq / lambda)) 39 | list(sig_sq = sig_sq, mu = mu) 40 | } 41 | 42 | pNormalInverseGamma <- function(x, sig_sq, mu, lambda, alpha, beta) { 43 | num <- exp(-1 * (beta) / sig_sq) * (beta / sig_sq) ^ alpha * (erf(sqrt(lambda) * (x - mu) / (sqrt(2) * sqrt(sig_sq)) + 1)) 44 | den <- 2 * sig_sq * gamma(alpha) 45 | num / den 46 | } 47 | 48 | erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 49 | -------------------------------------------------------------------------------- /man/summary.bayesTest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{summary.bayesTest} 4 | \alias{summary.bayesTest} 5 | \title{Summarize bayesTest objects} 6 | \usage{ 7 | \method{summary}{bayesTest}( 8 | object, 9 | percentLift = rep(0, length(object$posteriors)), 10 | credInt = rep(0.9, length(object$posteriors)), 11 | ... 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{an object of class "bayesTest"} 16 | 17 | \item{percentLift}{a vector of length(x$posteriors). Each entry corresponds to the percent lift ((A - B) / B) to summarize for for 18 | the respective posterior in x. Note this is on a 'point' scale. percentLift = 5 implies you want to test for a 5\% lift.} 19 | 20 | \item{credInt}{a vector of length(x$posteriors). Each entry corresponds to the width of credible interval of (A - B) / B to calculate for 21 | the respective posterior in x. Also on a 'point' scale.} 22 | 23 | \item{...}{additional arguments affecting the summary produced.} 24 | } 25 | \value{ 26 | A \code{summaryBayesTest} object which contains summaries of the Posterior distributions, direct probabilities that A > B (by 27 | \code{percentLift}), credible intervals on (A - B) / B, and the Posterior Expected Loss on all estimated parameters. 28 | } 29 | \description{ 30 | Summary method for objects of class "bayesTest". 31 | } 32 | \note{ 33 | The Posterior Expected Loss (https://en.wikipedia.org/wiki/Bayes_estimator) is a good indicator of when to end a Bayesian 34 | AB test. If the PEL is lower than the absolute delta of the minimum effect you wish to detect, the test can be reasonably be stopped. 35 | } 36 | \examples{ 37 | A_pois <- rpois(100, 5) 38 | B_pois <- rpois(100, 4.7) 39 | 40 | AB1 <- bayesTest(A_pois, B_pois, priors = c('shape' = 25, 'rate' = 5), distribution = 'poisson') 41 | 42 | summary(AB1) 43 | summary(AB1, percentLift = 10, credInt = .95) 44 | 45 | } 46 | -------------------------------------------------------------------------------- /tests/testthat/test-bernoulliC.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesBernoulliCTest') 3 | 4 | A_data <- rbinom(100, 1, .5) 5 | B_data <- rbinom(100, 1, .6) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | test_that("Failures based on input types", { 12 | 13 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 5, 'beta' = 3, "jumanji" = 6), distribution = 'bernoulliC'), 14 | "Incorrect number of priors for supplied distribution.") 15 | 16 | expect_error(bayesTest(c(A_data, -3), B_data, priors = c('alpha' = 5, 'beta' = 3), distribution = 'bernoulliC'), 17 | "A_data %in% c(0, 1) are not all TRUE", fixed = TRUE) 18 | 19 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 1, 'fergalicious' = 1), distribution = 'bernoulliC'), 20 | "Misnamed priors provided for supplied distribution.") 21 | 22 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 'male', 'beta' = 1), distribution = 'bernoulliC'), 23 | "One or more priors aren't numeric.") 24 | 25 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 0, 'beta' = 1), distribution = 'bernoulliC'), 26 | "alpha > 0 is not TRUE") 27 | 28 | }) 29 | 30 | test_that("Success", { 31 | 32 | successfulTest <- bayesTest(A_data, B_data, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulliC') 33 | successfulTest2 <- bayesTest(A_data, B_data, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 34 | 35 | expect_is(successfulTest, "bayesTestClosed") 36 | 37 | expect_output(str(successfulTest), "List of 2") # outer 38 | expect_output(str(successfulTest), "List of 5") # inputs 39 | p1 <- summary(successfulTest)$probability$Probability 40 | p2 <- summary(successfulTest2)$probability$Probability 41 | expect_true(abs(p1 - p2) < .01) 42 | 43 | }) 44 | -------------------------------------------------------------------------------- /man/banditize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bandit.R 3 | \name{banditize} 4 | \alias{banditize} 5 | \title{Create a multi-armed Bayesian bandit object.} 6 | \usage{ 7 | banditize(bT, param, higher_is_better = TRUE) 8 | } 9 | \arguments{ 10 | \item{bT}{a bayesTest object} 11 | 12 | \item{param}{which model parameter (posterior) to evaluate; defaults to first param} 13 | 14 | \item{higher_is_better}{is a higher value of `param` equivalent to a better choice?} 15 | } 16 | \value{ 17 | A bayesBandit object. 18 | } 19 | \description{ 20 | Fit a multi-armed bandit object based on a bayesTest which can serve recommendations and adapt 21 | to new data. 22 | } 23 | \details{ 24 | \code{banditize} is an 'object-oriented' implementation of multi-armed bandits in \code{bayesAB}. It is useful in 25 | conjunction with a Shiny app or Plumber deployment. The object itself is mutable and can adapt/learn from new data without having to 26 | re-assign the variable. 27 | 28 | Comes with 5 methods: 29 | 30 | \itemize{ 31 | \item \code{serveRecipe()}: serves a recipe to show your user based on samples from both posteriors. 32 | \item \code{setResults(results)}: set results for one or more recipes for one or more instances of feedback. Used to update bandit. 33 | \item \code{getBayesTest()}: returns most updated \code{bayesTest} object. 34 | \item \code{getOriginalTest()}: returns original \code{bayesTest} object without any updates. 35 | \item \code{getUpdates()}: returns a summarized version of all updates this bandit has processed.} 36 | } 37 | \examples{ 38 | A_binom <- rbinom(100, 1, .5) 39 | B_binom <- rbinom(100, 1, .6) 40 | 41 | AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 42 | 43 | binomialBandit <- banditize(AB1) 44 | binomialBandit$serveRecipe() 45 | binomialBandit$setResults(list('A' = c(1, 0, 1, 0, 0), 'B' = c(0, 0, 0, 0, 1))) 46 | 47 | } 48 | -------------------------------------------------------------------------------- /man/plot.bayesTest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{plot.bayesTest} 4 | \alias{plot.bayesTest} 5 | \title{Plot bayesTest objects} 6 | \usage{ 7 | \method{plot}{bayesTest}( 8 | x, 9 | percentLift = rep(0, length(x$posteriors)), 10 | priors = TRUE, 11 | posteriors = TRUE, 12 | samples = TRUE, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{an object of class "bayesTest"} 18 | 19 | \item{percentLift}{a vector of length(x$posteriors). Each entry corresponds to the percent lift ((A - B) / B) to plot for for 20 | the respective posterior in x. Note this is on a 'point' scale. percentLift = 5 implies you want to test for a 5\% lift.} 21 | 22 | \item{priors}{logical indicating whether prior plots should be generated.} 23 | 24 | \item{posteriors}{logical indicating whether posterior plots should be generated.} 25 | 26 | \item{samples}{logical indicating whether sample plots should be generated.} 27 | 28 | \item{...}{graphics parameters to be passed to the plotting routines. (For example \code{p}, in prior plots)} 29 | } 30 | \description{ 31 | Plot method for objects of class "bayesTest". 32 | } 33 | \note{ 34 | You can either directly plot a bayesTest object (in which case it will plot interactively), or you can save the plot 35 | object to a variable and extract what you need separately. If extracted, you can treat it like any \code{ggplot2} object and 36 | modify it accordingly. 37 | 38 | Plots are slightly truncated on the extremes to solve the general case of potentially long tail-ends. 39 | } 40 | \examples{ 41 | A_pois <- rpois(100, 5) 42 | B_pois <- rpois(100, 4.7) 43 | 44 | AB1 <- bayesTest(A_pois, B_pois, priors = c('shape' = 25, 'rate' = 5), distribution = 'poisson') 45 | 46 | plot(AB1) 47 | \donttest{plot(AB1, percentLift = 5)} 48 | 49 | \donttest{ 50 | p <- plot(AB1) 51 | p$posteriors$Lambda 52 | } 53 | \dontrun{p$posteriors$Lambda + ggtitle('yolo') # modify ggplot2 object directly} 54 | 55 | } 56 | -------------------------------------------------------------------------------- /tests/testthat/test-lognormal.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesLogNormalTest') 3 | 4 | A_data <- rlnorm(100) 5 | B_data <- rlnorm(100) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('mu' = 5, 'lambda' = 3, 'alpha' = 3, 'beta' = 2) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'lognormal'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(A_data_bad_string, B_data, priors = priors, distribution = 'lognormal'), 19 | "is.numeric(A_data) is not TRUE", fixed = TRUE) 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'lognormal'), 22 | "Misnamed priors provided for supplied distribution.") 23 | 24 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'lambda' = -3), distribution = 'lognormal'), 25 | "lambda > 0 is not TRUE", fixed = TRUE) 26 | 27 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-3], 'alpha' = -3), distribution = 'lognormal'), 28 | "alpha > 0 is not TRUE", fixed = TRUE) 29 | 30 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-4], 'beta' = -3), distribution = 'lognormal'), 31 | "beta > 0 is not TRUE", fixed = TRUE) 32 | 33 | expect_error(bayesTest(c(A_data, -1), B_data, priors = priors, distribution = 'lognormal'), 34 | "A_data >= 0 are not all TRUE", fixed = TRUE) 35 | 36 | }) 37 | 38 | test_that("Success", { 39 | 40 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'lognormal') 41 | 42 | expect_is(successfulTest, "bayesTest") 43 | 44 | expect_output(str(successfulTest), "List of 5") # inputs 45 | expect_output(str(successfulTest), "List of 2") # outer 46 | expect_output(str(successfulTest), "List of 4") # inputs 47 | 48 | }) 49 | -------------------------------------------------------------------------------- /tests/testthat/test-poissonC.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesPoissonCTest') 3 | 4 | A_data <- rpois(100, 5) 5 | B_data <- rpois(100, 4) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | priors <- c('shape' = 5, 'rate' = 3) 12 | 13 | test_that("Failures based on input types", { 14 | 15 | expect_error(bayesTest(A_data, B_data, priors = c(priors, "jumanji" = 6), distribution = 'poissonC'), 16 | "Incorrect number of priors for supplied distribution.") 17 | 18 | expect_error(bayesTest(c(A_data, 3.5), B_data, priors = priors, distribution = 'poissonC'), 19 | "as.integer(A_data) == A_data are not all TRUE", fixed = TRUE) 20 | 21 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'fergalicious' = 1), distribution = 'poissonC'), 22 | "Misnamed priors provided for supplied distribution.") 23 | 24 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = 'cabbage'), distribution = 'poissonC'), 25 | "One or more priors aren't numeric.") 26 | 27 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-1], 'shape' = -3), distribution = 'poissonC'), 28 | "shape > 0 is not TRUE", fixed = TRUE) 29 | 30 | expect_error(bayesTest(A_data, B_data, priors = c(priors[-2], 'rate' = -3), distribution = 'poissonC'), 31 | "rate > 0 is not TRUE", fixed = TRUE) 32 | 33 | }) 34 | 35 | test_that("Success", { 36 | 37 | successfulTest <- bayesTest(A_data, B_data, priors = priors, distribution = 'poissonC') 38 | successfulTest2 <- bayesTest(A_data, B_data, priors = priors, distribution = 'poisson') 39 | 40 | 41 | expect_is(successfulTest, "bayesTestClosed") 42 | 43 | expect_output(str(successfulTest), "List of 2") # outer 44 | expect_output(str(successfulTest), "List of 5") # outer 45 | p1 <- summary(successfulTest)$probability$Lambda 46 | p2 <- summary(successfulTest2)$probability$Lambda 47 | expect_true(abs(p1 - p2) < .01) 48 | 49 | }) 50 | -------------------------------------------------------------------------------- /tests/testthat/test-bernoulli.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('bayesBernoulliTest') 3 | 4 | A_data <- rbinom(100, 1, .5) 5 | B_data <- rbinom(100, 1, .6) 6 | 7 | A_data_bad_string <- c(A_data, "porcupine") 8 | A_data_bad_prop <- c(A_data, .3) 9 | A_data_bad_non_unique <- c(A_data, 2) 10 | 11 | test_that("Failures based on input types", { 12 | 13 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 5, 'beta' = 3, "jumanji" = 6), distribution = 'bernoulli'), 14 | "Incorrect number of priors for supplied distribution.") 15 | 16 | expect_error(bayesTest(c(A_data, -3), B_data, priors = c('alpha' = 5, 'beta' = 3), distribution = 'bernoulli'), 17 | "A_data %in% c(0, 1) are not all TRUE", fixed = TRUE) 18 | 19 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 1, 'fergalicious' = 1), distribution = 'bernoulli'), 20 | "Misnamed priors provided for supplied distribution.") 21 | 22 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 'male', 'beta' = 1), distribution = 'bernoulli'), 23 | "One or more priors aren't numeric.") 24 | 25 | expect_error(bayesTest(A_data, B_data, priors = list('alpha' = 'male', 'beta' = 1), distribution = 'bernoulli'), 26 | "One or more priors aren't numeric.") 27 | 28 | expect_error(bayesTest(A_data, B_data, priors = c('alpha' = 1, 'beta' = 0), distribution = 'bernoulli'), 29 | "beta > 0 is not TRUE") 30 | 31 | }) 32 | 33 | test_that("Success", { 34 | 35 | successfulTest <- bayesTest(A_data, B_data, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 36 | successfulTestList <- bayesTest(A_data, B_data, priors = list('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 37 | 38 | expect_is(successfulTest, "bayesTest") 39 | expect_is(successfulTestList, "bayesTest") 40 | 41 | expect_output(str(successfulTest), "List of 5") # inputs 42 | expect_output(str(successfulTest), "List of 2") # outer 43 | expect_output(str(successfulTestList), "List of 5") # inputs 44 | expect_output(str(successfulTestList), "List of 2") # outer 45 | }) 46 | -------------------------------------------------------------------------------- /R/constructors.R: -------------------------------------------------------------------------------- 1 | constructors <- function() { 2 | list( 3 | "bernoulli" = list( 4 | prior = 'Beta', 5 | dataChecks = list( 6 | checkBinomialData 7 | ), 8 | priorChecks = list( 9 | checkBetaPriors 10 | ), 11 | posteriors = Bernoulli 12 | ), 13 | 14 | "bernoulliC" = list( 15 | prior = 'Beta', 16 | dataChecks = list( 17 | checkBinomialData 18 | ), 19 | priorChecks = list( 20 | checkBetaPriors 21 | ), 22 | posteriors = BernoulliClosed 23 | ), 24 | 25 | "normal" = list( 26 | prior = 'NormalInvGamma', 27 | dataChecks = list(), 28 | priorChecks = list( 29 | checkNormalInvGammaPriors 30 | ), 31 | posteriors = Normal 32 | ), 33 | 34 | "lognormal" = list( 35 | prior = 'NormalInvGamma', 36 | dataChecks = list( 37 | checkPositiveData, 38 | checkNotZeroData 39 | ), 40 | priorChecks = list( 41 | checkNormalInvGammaPriors 42 | ), 43 | posteriors = LogNormal 44 | ), 45 | 46 | "poisson" = list( 47 | prior = 'Gamma', 48 | dataChecks = list( 49 | checkPositiveData, 50 | checkIntegerData 51 | ), 52 | priorChecks = list( 53 | checkGammaPriors 54 | ), 55 | posteriors = Poisson 56 | ), 57 | 58 | "poissonC" = list( 59 | prior = 'Gamma', 60 | dataChecks = list( 61 | checkPositiveData, 62 | checkIntegerData 63 | ), 64 | priorChecks = list( 65 | checkGammaPriors 66 | ), 67 | posteriors = PoissonClosed 68 | ), 69 | 70 | "exponential" = list( 71 | prior = 'Gamma', 72 | dataChecks = list( 73 | checkPositiveData 74 | ), 75 | priorChecks = list( 76 | checkGammaPriors 77 | ), 78 | posteriors = Exponential 79 | ), 80 | 81 | "uniform" = list( 82 | prior = 'Pareto', 83 | dataChecks = list( 84 | checkPositiveData 85 | ), 86 | priorChecks = list( 87 | checkParetoPriors 88 | ), 89 | posteriors = Uniform 90 | ) 91 | ) 92 | } 93 | 94 | getDistribution <- function(distribution) constructors()[[distribution]] 95 | -------------------------------------------------------------------------------- /man/combine.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/combine.R 3 | \name{combine} 4 | \alias{combine} 5 | \title{Combine two \code{bayesAB} objects given a binary function.} 6 | \usage{ 7 | combine(bT1, bT2, f = `+`, params, newName) 8 | } 9 | \arguments{ 10 | \item{bT1}{a bayesTest object} 11 | 12 | \item{bT2}{a bayesTest object} 13 | 14 | \item{f}{a binary function (f(x, y)) used to combine posteriors from bT1 to bT2} 15 | 16 | \item{params}{a character vector of length 2, corresponding to names of the posterior parameters you want to combine; 17 | defaults to first posterior parameter if not supplied} 18 | 19 | \item{newName}{a string indicating the name of the new 'posterior' in the resulting object; 20 | defaults to string representation of f(params[1], params[2])} 21 | } 22 | \value{ 23 | a \code{bayesTest} object with the newly combined posterior samples. 24 | } 25 | \description{ 26 | Combine two (or any number, in succession) \code{bayesTest} objects into a new arbitrary posterior distribution. 27 | The resulting object is of the same class. 28 | } 29 | \note{ 30 | The generics `+.bayesTest`, `*.bayesTest`, `-.bayesTest`, and `/.bayesTest` are shorthand for 31 | combine(f = `+`), combine(f = `*`), combine(f = `-`), and combine(f = `/`). 32 | } 33 | \examples{ 34 | A_binom <- rbinom(100, 1, .5) 35 | B_binom <- rbinom(100, 1, .6) 36 | 37 | A_norm <- rnorm(100, 6, 1.5) 38 | B_norm <- rnorm(100, 5, 2.5) 39 | 40 | AB1 <- bayesTest(A_binom, B_binom, 41 | priors = c('alpha' = 1, 'beta' = 1), 42 | distribution = 'bernoulli') 43 | 44 | AB2 <- bayesTest(A_norm, B_norm, 45 | priors = c('mu' = 5, 'lambda' = 1, 'alpha' = 3, 'beta' = 1), 46 | distribution = 'normal') 47 | 48 | AB3 <- combine(AB1, AB2, f = `*`, params = c('Probability', 'Mu'), newName = 'Expectation') 49 | # Equivalent to 50 | AB3 <- AB1 * grab(AB2, 'Mu') 51 | 52 | # To get the same posterior name as well 53 | AB3 <- rename(AB3, 'Expectation') 54 | 55 | # Dummy example 56 | weirdVariable <- (AB1 + AB2) * (AB2 / AB1) 57 | weirdVariable <- rename(weirdVariable, 'confusingParam') 58 | 59 | print(AB3) 60 | summary(AB3) 61 | plot(AB3) 62 | } 63 | \seealso{ 64 | \code{\link{grab}} 65 | } 66 | -------------------------------------------------------------------------------- /man/bayesAB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bayesAB.R 3 | \docType{package} 4 | \name{bayesAB} 5 | \alias{bayesAB} 6 | \title{bayesAB: Fast Bayesian Methods for A/B Testing} 7 | \description{ 8 | bayesAB provides a suite of functions that allow the user to analyze A/B test 9 | data in a Bayesian framework. bayesAB is intended to be a drop-in replacement for 10 | common frequentist hypothesis test such as the t-test and chi-sq test. 11 | } 12 | \details{ 13 | Bayesian methods provide several benefits over frequentist methods in the context of 14 | A/B tests - namely in interpretability. Instead of p-values you get direct 15 | probabilities on whether A is better than B (and by how much). Instead of point estimates 16 | your posterior distributions are parametrized random variables which can be summarized 17 | any number of ways. Bayesian tests are also immune to 'peeking' and are thus valid whenever 18 | a test is stopped. 19 | 20 | The general bayesAB workflow is as follows: 21 | \itemize{ 22 | \item Decide how you want to parametrize your data (Poisson for counts of email submissions, Bernoulli for CTR on an ad, etc.) 23 | \item Use our helper functions to decide on priors for your data (\link{bayesTest}, \link{plotDistributions}) 24 | \item Fit a \link{bayesTest} object 25 | \itemize{ \item Optional: Use \link{combine} to munge together several \link{bayesTest} objects together for an arbitrary / non-analytical target distribution} 26 | \item \code{print}, \link{plot.bayesTest}, and \link{summary.bayesTest} to interpret your results 27 | \itemize{ \item Determine whether to stop your test early given the Posterior Expected Loss in \code{summary} output}} 28 | 29 | Optionally, use \link{banditize} and/or \link{deployBandit} to turn a pre-calculated (or empty) bayesTest into a multi-armed bandit that can serve 30 | recipe recommendations and adapt as new data comes in. 31 | 32 | Note, while bayesAB was designed to exploit data related to A/B/etc tests, you can use the package to conduct Bayesian analysis on 33 | virtually any vector of data, as long as it can be parametrized by the available functions. 34 | 35 | To learn more about bayesAB, start with the vignettes: 36 | \code{browseVignettes(package = "bayesAB")} 37 | } 38 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /R/bayesAB.R: -------------------------------------------------------------------------------- 1 | #' bayesAB: Fast Bayesian Methods for A/B Testing 2 | #' 3 | #' bayesAB provides a suite of functions that allow the user to analyze A/B test 4 | #' data in a Bayesian framework. bayesAB is intended to be a drop-in replacement for 5 | #' common frequentist hypothesis test such as the t-test and chi-sq test. 6 | #' 7 | #' Bayesian methods provide several benefits over frequentist methods in the context of 8 | #' A/B tests - namely in interpretability. Instead of p-values you get direct 9 | #' probabilities on whether A is better than B (and by how much). Instead of point estimates 10 | #' your posterior distributions are parametrized random variables which can be summarized 11 | #' any number of ways. Bayesian tests are also immune to 'peeking' and are thus valid whenever 12 | #' a test is stopped. 13 | #' 14 | #' The general bayesAB workflow is as follows: 15 | #' \itemize{ 16 | #' \item Decide how you want to parametrize your data (Poisson for counts of email submissions, Bernoulli for CTR on an ad, etc.) 17 | #' \item Use our helper functions to decide on priors for your data (\link{bayesTest}, \link{plotDistributions}) 18 | #' \item Fit a \link{bayesTest} object 19 | #' \itemize{ \item Optional: Use \link{combine} to munge together several \link{bayesTest} objects together for an arbitrary / non-analytical target distribution} 20 | #' \item \code{print}, \link{plot.bayesTest}, and \link{summary.bayesTest} to interpret your results 21 | #' \itemize{ \item Determine whether to stop your test early given the Posterior Expected Loss in \code{summary} output}} 22 | #' 23 | #' Optionally, use \link{banditize} and/or \link{deployBandit} to turn a pre-calculated (or empty) bayesTest into a multi-armed bandit that can serve 24 | #' recipe recommendations and adapt as new data comes in. 25 | #' 26 | #' Note, while bayesAB was designed to exploit data related to A/B/etc tests, you can use the package to conduct Bayesian analysis on 27 | #' virtually any vector of data, as long as it can be parametrized by the available functions. 28 | #' 29 | #' To learn more about bayesAB, start with the vignettes: 30 | #' \code{browseVignettes(package = "bayesAB")} 31 | #' 32 | #' @docType package 33 | #' @name bayesAB 34 | #' @importFrom graphics par 35 | #' @importFrom methods is 36 | #' @importFrom stats dbeta dnorm qgamma quantile rbeta rgamma rnorm dgamma dpois qpois runif dlnorm qlnorm pnorm var 37 | #' @importFrom utils tail packageVersion head 38 | #' @importFrom rlang .data 39 | #' @useDynLib bayesAB 40 | #' @importFrom Rcpp evalCpp 41 | NULL 42 | -------------------------------------------------------------------------------- /tests/testthat/test-generics.R: -------------------------------------------------------------------------------- 1 | library(bayesAB) 2 | context('generics') 3 | 4 | A_data <- rlnorm(100) 5 | B_data <- rlnorm(100) 6 | 7 | priors <- c('mu' = 5, 'lambda' = 3, 'alpha' = 3, 'beta' = 2) 8 | 9 | x <- bayesTest(A_data, B_data, priors = priors, distribution = 'lognormal') 10 | 11 | A_binom<- rbinom(100, 1, .5) 12 | B_binom <- rbinom(100, 1, .6) 13 | 14 | AB3 <- bayesTest(A_binom, B_binom, 15 | priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulliC') 16 | 17 | AB4 <- bayesTest(A_binom, B_binom, 18 | priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 19 | 20 | test_that("Failures based on inputs", { 21 | 22 | expect_error(plot(x, percentLift = 0), "Must supply a 'percentLift' for every parameter with a posterior distribution.") 23 | 24 | expect_error(plot(x, priors = FALSE, posteriors = FALSE, samples = FALSE), "Must specifiy at least one plot to make.") 25 | 26 | expect_error(summary(x, percentLift = 0), "Must supply a 'percentLift' for every parameter with a posterior distribution.") 27 | 28 | expect_error(summary(x, credInt = 0), "Must supply a 'credInt' for every parameter with a posterior distribution.") 29 | 30 | expect_error(c(x, AB4), "Unable to concatenate. Mismatches in (A_data, B_data, priors, distribution). All inputs must be the same (except n_samples).", 31 | fixed = TRUE) 32 | 33 | expect_error(plot(AB3), "Can't plot 'closed form' bayesTest.", fixed = TRUE) 34 | 35 | expect_error(summary(x, credInt = c(5, 5, 5, 5)), "Credible interval width must be in (0, 1).", fixed = TRUE) 36 | 37 | }) 38 | 39 | test_that("Success", { 40 | 41 | expect_silent(plot(x)) 42 | expect_silent(plot(x, rep(.5, 4))) 43 | expect_equal(length(plot(x, posteriors = FALSE, samples = FALSE)$priors), 1) 44 | expect_equal(names(plot(x, posteriors = FALSE, samples = FALSE)$priors), c('NormalInvGamma')) 45 | 46 | expect_silent(print(plot(x))) 47 | expect_silent(print(plot(x, rep(.5, 4)))) 48 | 49 | expect_output(print(x), "Distribution used") 50 | 51 | expect_silent(summary(x)) 52 | expect_silent(summary(x, rep(.5, 4))) 53 | expect_silent(summary(x, rep(.5, 4), rep(.5, 4))) 54 | 55 | expect_output(print(summary(x)), 'P(A > B)', fixed = TRUE) 56 | expect_output(print(summary(AB3)), 'P(A > B)', fixed = TRUE) 57 | 58 | expect_is(c(x, x), "bayesTest") 59 | expect_identical(rep(x$posteriors$Mu$A, 2), c(x, x)$posteriors$Mu$A) 60 | expect_identical(rep(x$posteriors$Mu$B, 2), c(x, x)$posteriors$Mu$B) 61 | expect_identical(rep(x$posteriors$Mu$A, 3), c(x, x, x)$posteriors$Mu$A) 62 | 63 | }) 64 | -------------------------------------------------------------------------------- /docs/jquery.sticky-kit.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net 3 | */ 4 | (function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); 5 | if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, 6 | u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), 8 | a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", 9 | y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent; 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /R/makePlots.R: -------------------------------------------------------------------------------- 1 | # Plot priors based on matching of prior params in bayesAB test object 2 | plotPriors <- function(bayesAB) { 3 | p <- NULL 4 | if(bayesAB$inputs$distribution != 'combined') { 5 | p <- list(do.call(getDistPlotFunc(bayesAB$prior), bayesAB$inputs$priors)) 6 | names(p) <- bayesAB$prior 7 | } 8 | p 9 | } 10 | 11 | # Plot samples based on lift, name of var, and data 12 | samplePlot <- function(A, B, name, percentLift, f = function(a, b) (a-b)/b) { 13 | 14 | under <- NULL # CRAN NSE hack 15 | 16 | diff <- f(A, B) 17 | cutoff <- percentLift / 100 18 | inner <- quantile(diff, c(.005, .995)) 19 | 20 | # Always include percentLift in the plot 21 | inner[1] <- min(inner[1], cutoff) 22 | inner[2] <- max(inner[2], cutoff) 23 | 24 | diff <- data.frame(diff = diff, 25 | under = diff < cutoff, 26 | inside = diff >= inner[1] & diff <= inner[2]) 27 | 28 | prop <- 1 - sum(diff$under) / nrow(diff) 29 | prop <- round(prop * 100, digits = 1) 30 | 31 | p <- ggplot2::qplot(diff, 32 | data = diff, 33 | fill = under, 34 | binwidth = diff(range(inner)) / 250, 35 | na.rm = TRUE) + 36 | ggplot2::scale_fill_manual(values = c('TRUE' = '#00B6EB', 'FALSE' = '#F8766D')) + 37 | ggplot2::geom_vline(xintercept = cutoff) + 38 | ggplot2::xlim(inner[1], inner[2]) 39 | 40 | m <- max(ggplot2::ggplot_build(p)$layout$panel_params[[1]]$y.range) 41 | 42 | xpos <- mean(diff$diff[diff$under == F & diff$inside == T]) 43 | if(is.nan(xpos)) xpos <- mean(diff$diff[diff$under == T & diff$inside == T]) 44 | 45 | p <- p + ggplot2::annotate('text', x = xpos, y = m / 3, label = paste(prop, '%', sep = ""), size = 6) + 46 | ggplot2::xlab('(A - B) / B') + 47 | ggplot2::ylab('Density') + 48 | ggplot2::ggtitle(paste0('Histogram of (A - B) / B Samples : ', name)) + 49 | ggplot2::guides(fill = "none") 50 | 51 | p 52 | 53 | } 54 | 55 | # Plot posteriors (samples only, not closed form distribution) 56 | posteriorPlot <- function(A, B, name) { 57 | 58 | value <- recipe <- NULL #CRAN NSE hack 59 | 60 | makeDF <- function(dat) data.frame(recipe = deparse(substitute(dat)), value = dat) 61 | A <- makeDF(A) 62 | B <- makeDF(B) 63 | plotDat <- rbind(A, B) 64 | 65 | p <- ggplot2::ggplot(plotDat, ggplot2::aes(x = value, group = recipe, fill = recipe)) + 66 | ggplot2::geom_density(alpha = 0.75) + 67 | ggplot2::xlab(NULL) + 68 | ggplot2::ylab('Density') + 69 | ggplot2::ggtitle(paste0('A and B, ', name, ' Posteriors')) + 70 | ggplot2::guides(fill = ggplot2::guide_legend(title = NULL)) 71 | 72 | p 73 | 74 | } 75 | 76 | # Constructor function for plotSamples and plotPosteriors 77 | plotConstructor <- function(fun, lift) { 78 | function(bayesAB, ...) { 79 | out <- vector(mode = 'list', length = length(bayesAB$posteriors)) 80 | names(out) <- names(bayesAB$posteriors) 81 | 82 | lifts <- c(...) 83 | 84 | for(i in seq_along(bayesAB$posteriors)) { 85 | p <- bayesAB$posteriors[[i]] 86 | call <- list(A = p$A, B = p$B, name = names(out)[i]) 87 | if(lift) call <- c(call, percentLift = lifts[i]) 88 | pl <- do.call(fun, call) 89 | pl <- pl + theme_bayesAB() 90 | pl <- list(pl) 91 | out[i] <- pl 92 | } 93 | return(out) 94 | } 95 | } 96 | 97 | theme_bayesAB <- function() { 98 | ggplot2::theme_minimal() + 99 | ggplot2::theme(axis.text.x = ggplot2::element_text(face = "bold", size = 12), 100 | axis.text.y = ggplot2::element_text(face = "bold", size = 12), 101 | title = ggplot2::element_text(size = 12)) 102 | } 103 | 104 | plotSamples <- plotConstructor(samplePlot, TRUE) 105 | plotPosteriors <- plotConstructor(posteriorPlot, FALSE) 106 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # bayesAB 1.1.3 2 | 3 | ## Minor Changes 4 | * Fix ggplot2 deprecation warning introduced in latest version. 5 | 6 | # bayesAB 1.1.2 7 | 8 | ## Minor Changes 9 | * Fix documentation to reflect the changes to `NormalInverseGamma` in `1.1.0`. 10 | 11 | # bayesAB 1.1.1 12 | 13 | ## Minor Changes 14 | * Bug fixes for most recent version of ggplot2. Hopefully the API is stabe from here on out. 15 | * Fixed `grab` to correctly return the `priors` property in addition to `posteriors` and `inputs`. 16 | * Fixed the `print` generic for the `bayesTestClosed` types to error out informatively 17 | 18 | # bayesAB 1.1.0 19 | 20 | ## Breaking 21 | * Changed conjugate prior of Normal/LogNormal distributions to be the `NormalInverseGamma` distribution from a combination of the `Normal` and `Inverse Gamma` distributions. This distribution is bivariate and gives us a 2d estimate for both `x` and `sig_sq`. The params for this distribution are `mu`, `lambda`, `alpha`, `beta` and are different from the old priors that Normal/LogNormal were expecting. 22 | 23 | * Various doc changes to illustrate these changes and new expectations 24 | 25 | ## Major Changes 26 | * Fix closed form distributions and added tests 27 | * Calculation Posterior Expected Loss is now correct and represents a true loss function 28 | * Added `plotNormalInvGamma` 29 | 30 | ## Minor Changes 31 | * Colors for sample plots are now hardcoded (red for > 0 and blue for < 0) 32 | * Plots are truncated at the extremes to avoid very long tails 33 | 34 | # bayesAB 1.0.0 35 | 36 | ## Major Additions 37 | 38 | * Added `grab` and `rename` to retrieve and rename posteriors from your `bayesTest` object 39 | 40 | * Mostly useful in conjunction with `combine` in order to quickly chain together several `bayesTest`s 41 | 42 | * Correctly hide legend for generic plots 43 | * Standardized prior parameters to have the same arguments as the `plot{Dist}` functions 44 | 45 | * This mostly changes prior inputs for `bayesTest(distribution = c('normal', 'lognormal'))` 46 | * This is a **breaking** change 47 | 48 | ## Major Internal Changes 49 | 50 | * Moved `distribution` metadata from `bayesTest$distribution` to `bayesTest$inputs$distribution` to be consistent 51 | * Reconcile posterior names to always be `A` and `B` and not include the parameter name 52 | * `A_data` and `B_data` in inputs are now always lists by default to make `combine` work more simply 53 | * Big refactor of how `bayesTest` works internally. Dispatch per distribution is now only related to how the posterior is calculated. 54 | * Some error checking has been made more generic 55 | 56 | ## Minor Tweaks/Fixed 57 | 58 | * Posterior Expected Loss now correctly displays 0 instead of NaN for that case 59 | * Numerous doc/examples/tests cleanup 60 | * Overall refactor of some methods, making it easier to read and contribute 61 | 62 | # bayesAB 0.7.0 63 | 64 | ## Major Additions 65 | 66 | * added `banditize` and `deployBandit` to turn your `bayesTest` object into a Bayesian multi*armed bandit and deploy as a JSON API respectively. 67 | * Added programmatic capabilities on top of existing interactive uses for `plot` generic function 68 | 69 | * You can now assign `plot(bayesTestObj)` to a variable and not have it automatically plot. 70 | 71 | * Added quantile summary of calculated posteriors to the output of `summary.bayesTest` 72 | * Added Posterior Expected Loss to output of `summary.bayesTest` 73 | 74 | * This is useful to know when to stop your Bayesian AB Test 75 | * Supports the risk of choosing 'B' over 'A' (ordering is important) and makes more sense if A > B currently in the test 76 | 77 | ## Minor Tweaks/Fixes 78 | 79 | * outputs from `plot` generics are now explicitly `ggplot` objects and can be modified as such 80 | 81 | * You can input your own titles/axis labels/etc if the defaults don't fit your use case 82 | 83 | # bayesAB 0.6.0 84 | 85 | ## Major Additions 86 | 87 | * First major CRAN release 88 | * 6 (+ 2) distributions 89 | * `print`, `plot`, `summary` generics 90 | * Easy plotting of distributions for quick visual inspection 91 | * `combine` tests as needed 92 | * 100% code coverage 93 | -------------------------------------------------------------------------------- /R/posteriors.R: -------------------------------------------------------------------------------- 1 | Bernoulli <- function(A_data, 2 | B_data, 3 | n_samples, 4 | alpha, 5 | beta) { 6 | map <- function(data) rbeta(n_samples, sum(data) + alpha, length(data) - sum(data) + beta) 7 | list( 8 | Probability = list(A = map(A_data), B = map(B_data)) 9 | ) 10 | } 11 | 12 | BernoulliClosed <- function(A_data, 13 | B_data, 14 | alpha, 15 | beta) { 16 | prob <- BernoulliClosed_(sum(A_data) + alpha, 17 | length(A_data) - sum(A_data) + beta, 18 | sum(B_data) + alpha, 19 | length(B_data) - sum(B_data) + beta) 20 | list(Probability = prob) 21 | } 22 | 23 | Exponential <- function(A_data, 24 | B_data, 25 | n_samples, 26 | shape, 27 | rate) { 28 | map <- function(data) rgamma(n_samples, length(data) + shape, sum(data) + rate) 29 | list( 30 | Lambda = list(A = map(A_data), B = map(B_data)) 31 | ) 32 | } 33 | 34 | Normal <- function(A_data, 35 | B_data, 36 | n_samples, 37 | mu, 38 | lambda, 39 | alpha, 40 | beta) { 41 | A <- drawMusAndSigmas(A_data, mu, lambda, alpha, beta, n_samples) 42 | B <- drawMusAndSigmas(B_data, mu, lambda, alpha, beta, n_samples) 43 | 44 | A_mus <- A$mu 45 | B_mus <- B$mu 46 | 47 | A_sig_sqs <- A$sig_sq 48 | B_sig_sqs <- B$sig_sq 49 | 50 | list( 51 | Mu = list(A = A_mus, B = B_mus), 52 | Sig_Sq = list(A = A_sig_sqs, B = B_sig_sqs) 53 | ) 54 | } 55 | 56 | LogNormal <- function(A_data, 57 | B_data, 58 | n_samples, 59 | mu, 60 | lambda, 61 | alpha, 62 | beta) { 63 | NormalResult <- Normal(log(A_data), 64 | log(B_data), 65 | n_samples, 66 | mu, 67 | lambda, 68 | alpha, 69 | beta) 70 | 71 | ## Means 72 | A_mus <- NormalResult$Mu$A 73 | B_mus <- NormalResult$Mu$B 74 | 75 | ## Sigmas 76 | A_sig_sqs <- NormalResult$Sig_Sq$A 77 | B_sig_sqs <- NormalResult$Sig_Sq$B 78 | 79 | ## Transform back to log normal for interpretation 80 | A_means <- exp(A_mus + A_sig_sqs / 2) 81 | B_means <- exp(B_mus + B_sig_sqs / 2) 82 | 83 | A_vars <- (exp(A_sig_sqs) - 1) * exp(2 * A_mus + A_sig_sqs) 84 | B_vars <- (exp(B_sig_sqs) - 1) * exp(2 * B_mus + B_sig_sqs) 85 | 86 | list( 87 | Mu = list(A = A_mus, B = B_mus), 88 | Sig_Sq = list(A = A_sig_sqs, B = B_sig_sqs), 89 | Mean = list(A = A_means, B = B_means), 90 | Var = list(A = A_vars, B = B_vars) 91 | ) 92 | } 93 | 94 | Poisson <- function(A_data, 95 | B_data, 96 | n_samples, 97 | shape, 98 | rate) { 99 | map <- function(data) rgamma(n_samples, sum(data) + shape, length(data) + rate) 100 | list( 101 | Lambda = list(A = map(A_data), B = map(B_data)) 102 | ) 103 | } 104 | 105 | PoissonClosed <- function(A_data, 106 | B_data, 107 | shape, 108 | rate) { 109 | prob <- PoissonClosed_(sum(A_data) + shape, 110 | length(A_data) + rate, 111 | sum(B_data) + shape, 112 | length(B_data) + rate) 113 | list(Lambda = prob) 114 | } 115 | 116 | Uniform <- function(A_data, 117 | B_data, 118 | n_samples, 119 | xm, 120 | alpha) { 121 | map <- function(data) rpareto(n_samples, max(data, xm), length(data) + alpha) 122 | list( 123 | Theta = list(A = map(A_data), B = map(B_data)) 124 | ) 125 | } 126 | -------------------------------------------------------------------------------- /docs/LICENSE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | License • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 |
    41 |
    42 | 94 | 95 | 96 |
    97 | 98 |
    99 |
    100 | 103 | 104 |
    YEAR: 2016
    105 | COPYRIGHT HOLDER: Frank Portman
    106 | 
    107 | 108 |
    109 | 110 |
    111 | 112 | 113 |
    114 | 117 | 118 |
    119 |

    Site built with pkgdown.

    120 |
    121 | 122 |
    123 |
    124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /R/combine.R: -------------------------------------------------------------------------------- 1 | #' Combine two \code{bayesAB} objects given a binary function. 2 | #' 3 | #' @description Combine two (or any number, in succession) \code{bayesTest} objects into a new arbitrary posterior distribution. 4 | #' The resulting object is of the same class. 5 | #' 6 | #' @param bT1 a bayesTest object 7 | #' @param bT2 a bayesTest object 8 | #' @param f a binary function (f(x, y)) used to combine posteriors from bT1 to bT2 9 | #' @param params a character vector of length 2, corresponding to names of the posterior parameters you want to combine; 10 | #' defaults to first posterior parameter if not supplied 11 | #' @param newName a string indicating the name of the new 'posterior' in the resulting object; 12 | #' defaults to string representation of f(params[1], params[2]) 13 | #' @return a \code{bayesTest} object with the newly combined posterior samples. 14 | #' 15 | #' @note The generics `+.bayesTest`, `*.bayesTest`, `-.bayesTest`, and `/.bayesTest` are shorthand for 16 | #' combine(f = `+`), combine(f = `*`), combine(f = `-`), and combine(f = `/`). 17 | #' 18 | #' @seealso \code{\link{grab}} 19 | #' 20 | #' @examples 21 | #' A_binom <- rbinom(100, 1, .5) 22 | #' B_binom <- rbinom(100, 1, .6) 23 | #' 24 | #' A_norm <- rnorm(100, 6, 1.5) 25 | #' B_norm <- rnorm(100, 5, 2.5) 26 | #' 27 | #' AB1 <- bayesTest(A_binom, B_binom, 28 | #' priors = c('alpha' = 1, 'beta' = 1), 29 | #' distribution = 'bernoulli') 30 | #' 31 | #' AB2 <- bayesTest(A_norm, B_norm, 32 | #' priors = c('mu' = 5, 'lambda' = 1, 'alpha' = 3, 'beta' = 1), 33 | #' distribution = 'normal') 34 | #' 35 | #' AB3 <- combine(AB1, AB2, f = `*`, params = c('Probability', 'Mu'), newName = 'Expectation') 36 | #' # Equivalent to 37 | #' AB3 <- AB1 * grab(AB2, 'Mu') 38 | #' 39 | #' # To get the same posterior name as well 40 | #' AB3 <- rename(AB3, 'Expectation') 41 | #' 42 | #' # Dummy example 43 | #' weirdVariable <- (AB1 + AB2) * (AB2 / AB1) 44 | #' weirdVariable <- rename(weirdVariable, 'confusingParam') 45 | #' 46 | #' print(AB3) 47 | #' summary(AB3) 48 | #' plot(AB3) 49 | #' @export 50 | combine <- function(bT1, bT2, f = `+`, params, newName) { 51 | if( 52 | any( 53 | isClosed(bT1$inputs$distribution), 54 | isClosed(bT2$inputs$distribution) 55 | ) 56 | ) stop("Can't combine a 'closed' bayesTest.") 57 | 58 | if(missing(params)) { 59 | params <- c(NA, NA) 60 | params[1] <- names(bT1$posteriors)[1] 61 | params[2] <- names(bT2$posteriors)[1] 62 | } 63 | 64 | if(missing(newName)) { 65 | input <- paste0(params, collapse = ", ") 66 | input <- paste0('(', input, ')') 67 | newName <- paste0(toString(substitute(f)), input) 68 | } 69 | 70 | if(length(params) != 2) stop('You must specify only (2) params - one for the first test and one for the second test.') 71 | 72 | if(!((params[1] %in% names(bT1$posteriors)) & (params[2] %in% names(bT2$posteriors)))) { 73 | stop("You have specified a `param` name that doesn't exist in the posterior of the first test and/or the second test.") 74 | } 75 | 76 | if(bT1$inputs$n_samples != bT2$inputs$n_samples) warning("n_samples not equal. Make sure `f` handles recycling appropriately.") 77 | 78 | A1 <- bT1$posteriors[[params[1]]]$A; A2 <- bT2$posteriors[[params[2]]]$A 79 | B1 <- bT1$posteriors[[params[1]]]$B; B2 <- bT2$posteriors[[params[2]]]$B 80 | 81 | result <- list() 82 | 83 | result$inputs <- list( 84 | A_data = c(bT1$inputs$A_data, bT2$inputs$A_data), 85 | B_data = c(bT1$inputs$B_data, bT2$inputs$B_data), 86 | priors = 'Combined distributions have no priors. Inspect each element separately for details.', 87 | n_samples = max(bT1$inputs$n_samples, bT2$inputs$n_samples), 88 | distribution = 'combined' 89 | ) 90 | 91 | result$prior <- NULL 92 | result$posteriors[[newName]] <- list(A = f(A1, A2), B = f(B1, B2)) 93 | 94 | class(result) <- c('bayesTest') 95 | 96 | return(result) 97 | 98 | } 99 | 100 | #' @export 101 | `+.bayesTest` <- function(e1, e2) combine(e1, e2, f = `+`) 102 | 103 | #' @export 104 | `*.bayesTest` <- function(e1, e2) combine(e1, e2, f = `*`) 105 | 106 | #' @export 107 | `-.bayesTest` <- function(e1, e2) combine(e1, e2, f = `-`) 108 | 109 | #' @export 110 | `/.bayesTest` <- function(e1, e2) combine(e1, e2, f = `/`) 111 | 112 | #' Grab the supplied posterior from a bayesTest object 113 | #' 114 | #' @description Grab the supplied posterior from a bayesTest object, returning another bayesTest object. 115 | #' 116 | #' @param bT a bayesTest object 117 | #' @param posterior the name of a posterior in that object (string) 118 | #' 119 | #' @return a \code{bayesTest} object with the posterior parameter isolated 120 | #' 121 | #' @seealso \code{\link{combine}} 122 | #' 123 | #' @export 124 | grab <- function(bT, posterior) { 125 | if(! posterior %in% names(bT$posteriors)) stop("That posterior doesn't exist in the input bayesTest.") 126 | result <- list( 127 | prior = bT$prior, 128 | inputs = bT$inputs, 129 | posteriors = bT$posteriors[posterior] 130 | ) 131 | 132 | class(result) <- 'bayesTest' 133 | return(result) 134 | } 135 | 136 | #' Rename the posterior for a bayesTest object 137 | #' 138 | #' @description Rename the posterior param for a bayesTest object. 139 | #' 140 | #' @param bT a bayesTest object 141 | #' @param newName the new name you want for the posterior param (string) 142 | #' 143 | #' @return a \code{bayesTest} object with the posterior parameter renamed 144 | #' 145 | #' @seealso \code{\link{combine}} 146 | #' 147 | #' @export 148 | rename <- function(bT, newName) { 149 | if(length(bT$posteriors) != 1) stop('Can only rename bayesTests with one posterior.') 150 | names(bT$posteriors) <- newName 151 | return(bT) 152 | } 153 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Authors • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
    62 |
    63 | 120 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 130 | 131 |
      132 |
    • 133 |

      Frank Portman. Author, maintainer. 134 |

      135 |
    • 136 |
    137 | 138 |
    139 | 140 |
    141 | 142 | 143 | 144 |
    145 | 148 | 149 |
    150 |

    Site built with pkgdown 1.6.1.

    151 |
    152 | 153 |
    154 |
    155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | License • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
    62 |
    63 | 120 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 130 | 131 |
    YEAR: 2016
    132 | COPYRIGHT HOLDER: Frank Portman
    133 | 
    134 | 135 |
    136 | 137 | 142 | 143 |
    144 | 145 | 146 | 147 |
    148 | 151 | 152 |
    153 |

    Site built with pkgdown 1.6.1.

    154 |
    155 | 156 |
    157 |
    158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
    62 |
    63 | 120 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 130 | 131 |
    132 |

    All vignettes

    133 |

    134 | 135 |
    136 |
    Priors and Bayesian AB Testing
    137 |
    138 |
    Introduction to bayesAB
    139 |
    140 |
    141 |
    142 |
    143 |
    144 | 145 | 146 |
    147 | 150 | 151 |
    152 |

    Site built with pkgdown 1.6.1.

    153 |
    154 | 155 |
    156 |
    157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bayesAB 2 | 3 | [![Travis-CI Build Status](https://travis-ci.com/FrankPortman/bayesAB.svg?branch=master)](https://travis-ci.com/github/FrankPortman/bayesAB) [![codecov](https://codecov.io/gh/FrankPortman/bayesAB/branch/master/graph/badge.svg)](https://codecov.io/gh/FrankPortman/bayesAB) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/bayesAB)](https://CRAN.R-project.org/package=bayesAB) 4 | 5 | 6 | ## Fast Bayesian Methods for AB Testing 7 | 8 | bayesAB provides a suite of functions that allow the user to analyze A/B test 9 | data in a Bayesian framework. bayesAB is intended to be a drop-in replacement for 10 | common frequentist hypothesis test such as the t-test and chi-sq test. 11 | 12 | Bayesian methods provide several benefits over frequentist methods in the context of 13 | A/B tests - namely in interpretability. Instead of p-values you get direct 14 | probabilities on whether A is better than B (and by how much). Instead of point estimates 15 | your posterior distributions are parametrized random variables which can be summarized 16 | any number of ways. 17 | 18 | While Bayesian AB tests are still not immune to peeking in the broadest 19 | sense, you can use the 'Posterior Expected Loss' provided in the package to draw conclusions 20 | at any point with respect to your threshold for error. 21 | 22 | The general bayesAB workflow is as follows: 23 | 24 | - Decide how you want to parametrize your data (Poisson for counts of email submissions, Bernoulli for CTR on an ad, etc.) 25 | - Use our helper functions to decide on priors for your data (`?bayesTest`, `?plotDistributions`) 26 | - Fit a `bayesTest` object 27 | - Optional: Use `combine` to munge together several `bayesTest` objects together for an arbitrary / non-analytical target distribution 28 | - `print`, `plot`, and `summary` to interpret your results 29 | - Determine whether to stop your test early given the Posterior Expected Loss in `summary` output 30 | 31 | Optionally, use `banditize` and/or `deployBandit` to turn a pre-calculated (or empty) `bayesTest` into a multi-armed bandit that can serve recipe recommendations and adapt as new data comes in. 32 | 33 | Note, while bayesAB was designed to exploit data related to A/B/etc tests, you can use the package to conduct Bayesian analysis on virtually any vector of data, as long as it can be parametrized by the available functions. 34 | 35 | ## Installation 36 | 37 | Get the latest stable release from CRAN: 38 | ``` r 39 | install.packages("bayesAB") 40 | ``` 41 | 42 | Or the dev version straight from Github: 43 | ``` r 44 | install.packages("devtools") 45 | devtools::install_github("frankportman/bayesAB", build_vignettes = TRUE) 46 | ``` 47 | 48 | ## Usage 49 | 50 | Some useful links from my blog with `bayesAB` examples (and pictures!!): 51 | 52 | - [bayesAB: A New R Package for Bayesian AB Testing](http://fportman.com/writing/bayesab-a-new-r-package-for-bayesian-ab-testing/) 53 | - [bayesAB 0.7.0 + a Primer on Priors](http://fportman.com/writing/bayesab-0-dot-7-0-plus-a-primer-on-priors/) 54 | 55 | For a more in-depth look please check the package vignettes with `browseVignettes(package = "bayesAB")` or the pre-knit HTML version on CRAN [here](https://CRAN.R-project.org/package=bayesAB/vignettes/introduction.html). Brief example below. Run the following code for a quick overview of bayesAB: 56 | 57 | ``` r 58 | library(bayesAB) 59 | 60 | # Choose bernoulli test priors 61 | plotBeta(2, 3) 62 | 63 | ``` 64 | 65 | ![image](https://user-images.githubusercontent.com/2442871/27848261-b3fcb34a-60f8-11e7-99f5-224b802d91d5.png) 66 | 67 | ``` r 68 | # Choose normal test priors 69 | plotInvGamma(12, 4) 70 | 71 | ``` 72 | 73 | ![image](https://user-images.githubusercontent.com/2442871/27848279-cfe19166-60f8-11e7-92dd-58462e9a67e8.png) 74 | 75 | ``` r 76 | A_binom <- rbinom(100, 1, .5) 77 | B_binom <- rbinom(100, 1, .55) 78 | 79 | # Fit bernoulli test 80 | AB1 <- bayesTest(A_binom, 81 | B_binom, 82 | priors = c('alpha' = 1, 'beta' = 1), 83 | distribution = 'bernoulli') 84 | 85 | plot(AB1) 86 | 87 | ``` 88 | 89 | ![image](https://user-images.githubusercontent.com/2442871/27848286-dfbbac3e-60f8-11e7-8d18-bac057aad6b1.png) ![image](https://user-images.githubusercontent.com/2442871/27848293-ede96ea4-60f8-11e7-930e-ba07ded67ae1.png) ![image](https://user-images.githubusercontent.com/2442871/27848297-f5d18624-60f8-11e7-8d87-71edfc3a5616.png) 90 | 91 | ``` r 92 | print(AB1) 93 | 94 | ``` 95 | 96 | ``` 97 | -------------------------------------------- 98 | Distribution used: bernoulli 99 | -------------------------------------------- 100 | Using data with the following properties: 101 | A B 102 | Min. 0.00 0.00 103 | 1st Qu. 0.00 0.00 104 | Median 1.00 0.00 105 | Mean 0.55 0.44 106 | 3rd Qu. 1.00 1.00 107 | Max. 1.00 1.00 108 | -------------------------------------------- 109 | Priors used for the calculation: 110 | $alpha 111 | [1] 1 112 | 113 | $beta 114 | [1] 1 115 | 116 | -------------------------------------------- 117 | Calculated posteriors for the following parameters: 118 | Probability 119 | -------------------------------------------- 120 | Monte Carlo samples generated per posterior: 121 | [1] 1e+05 122 | 123 | ``` 124 | 125 | ``` r 126 | summary(AB1) 127 | 128 | ``` 129 | 130 | ``` 131 | Quantiles of posteriors for A and B: 132 | 133 | $Probability 134 | $Probability$A 135 | 0% 25% 50% 75% 100% 136 | 0.3330638 0.5159872 0.5496165 0.5824940 0.7507997 137 | 138 | $Probability$B 139 | 0% 25% 50% 75% 100% 140 | 0.2138149 0.4079403 0.4407221 0.4742673 0.6369742 141 | 142 | 143 | -------------------------------------------- 144 | 145 | P(A > B) by (0)%: 146 | 147 | $Probability 148 | [1] 0.93912 149 | 150 | -------------------------------------------- 151 | 152 | Credible Interval on (A - B) / B for interval length(s) (0.9) : 153 | 154 | $Probability 155 | 5% 95% 156 | -0.01379425 0.58463290 157 | 158 | -------------------------------------------- 159 | 160 | Posterior Expected Loss for choosing A over B: 161 | 162 | $Probability 163 | [1] 0.03105786 164 | 165 | ``` 166 | -------------------------------------------------------------------------------- /R/bandit.R: -------------------------------------------------------------------------------- 1 | #' Create a multi-armed Bayesian bandit object. 2 | #' 3 | #' @description Fit a multi-armed bandit object based on a bayesTest which can serve recommendations and adapt 4 | #' to new data. 5 | #' 6 | #' @param bT a bayesTest object 7 | #' @param param which model parameter (posterior) to evaluate; defaults to first param 8 | #' @param higher_is_better is a higher value of `param` equivalent to a better choice? 9 | #' @return A bayesBandit object. 10 | #' 11 | #' @details \code{banditize} is an 'object-oriented' implementation of multi-armed bandits in \code{bayesAB}. It is useful in 12 | #' conjunction with a Shiny app or Plumber deployment. The object itself is mutable and can adapt/learn from new data without having to 13 | #' re-assign the variable. 14 | #' 15 | #' Comes with 5 methods: 16 | #' 17 | #' \itemize{ 18 | #' \item \code{serveRecipe()}: serves a recipe to show your user based on samples from both posteriors. 19 | #' \item \code{setResults(results)}: set results for one or more recipes for one or more instances of feedback. Used to update bandit. 20 | #' \item \code{getBayesTest()}: returns most updated \code{bayesTest} object. 21 | #' \item \code{getOriginalTest()}: returns original \code{bayesTest} object without any updates. 22 | #' \item \code{getUpdates()}: returns a summarized version of all updates this bandit has processed.} 23 | #' 24 | #' @examples 25 | #' A_binom <- rbinom(100, 1, .5) 26 | #' B_binom <- rbinom(100, 1, .6) 27 | #' 28 | #' AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 29 | #' 30 | #' binomialBandit <- banditize(AB1) 31 | #' binomialBandit$serveRecipe() 32 | #' binomialBandit$setResults(list('A' = c(1, 0, 1, 0, 0), 'B' = c(0, 0, 0, 0, 1))) 33 | #' 34 | #' @export 35 | banditize <- function(bT, param, higher_is_better = TRUE) { 36 | if(missing(param)) param <- names(bT$posteriors)[1] 37 | if(bT$inputs$distribution == 'combined') { 38 | stop("Can't turn arbitrary combined distribution into a Bayesian Bandit.") 39 | } 40 | 41 | ## Re-assign bT to be able to report the OG one later 42 | test <- bT 43 | oldA <- unlist(test$inputs$A_data, use.names = FALSE) 44 | oldB <- unlist(test$inputs$B_data, use.names = FALSE) 45 | 46 | ## Only 2 recipes for now 47 | choices <- c('A', 'B') 48 | 49 | ## switch for higher_is_better 50 | compareFun <- ifelse(higher_is_better, which.max, which.min) 51 | 52 | ## Initialize counters and updates tracking 53 | updates <- 0 54 | A_ctr <- 0 55 | B_ctr <- 0 56 | 57 | serveRecipe <- function() { 58 | ## exploit iid samples from posterior 59 | idx <- sample(test$inputs$n_samples, 1) 60 | A_sample <- test$posteriors[[param]]$A[idx] 61 | B_sample <- test$posteriors[[param]]$B[idx] 62 | 63 | return(choices[compareFun(c(A_sample, B_sample))]) 64 | } 65 | 66 | setResults <- function(results) { 67 | if(!(all(names(results) %in% choices))) stop("`results` list must only contain names 'A' and 'B'") 68 | if(is.null(results$A) & is.null(results$B)) stop("A and B can't both be NULL.") 69 | 70 | test <<- bayesTest(c(oldA, results$A), 71 | c(oldB, results$B), 72 | test$inputs$priors, 73 | test$inputs$n_samples, 74 | test$inputs$distribution) 75 | 76 | updates <<- updates + 1 77 | A_ctr <<- A_ctr + length(results$A) 78 | B_ctr <<- B_ctr + length(results$B) 79 | 80 | return(0) 81 | } 82 | 83 | getBayesTest <- function() { 84 | return(test) 85 | } 86 | 87 | getOriginalTest <- function() { 88 | return(bT) 89 | } 90 | 91 | getUpdates <- function() { 92 | cat(updates, "updates to this bandit.\n") 93 | 94 | summarizeUpdates <- function(vec, name) cat(name, "has had", length(vec), "additions with a mean of", mean(vec), ".\n") 95 | 96 | summarizeUpdates(tail(test$inputs$A_data$A, A_ctr), "A") 97 | summarizeUpdates(tail(test$inputs$B_data$B, B_ctr), "B") 98 | } 99 | 100 | out <- list( 101 | "serveRecipe" = serveRecipe, 102 | "setResults" = setResults, 103 | "getBayesTest" = getBayesTest, 104 | "getOriginalTest" = getOriginalTest, 105 | "getUpdates" = getUpdates 106 | ) 107 | 108 | class(out) <- 'bayesBandit' 109 | 110 | return(out) 111 | 112 | } 113 | 114 | #' Deploy a bayesBandit object as a JSON API. 115 | #' 116 | #' @description Turn your bayesBandit object into an API and serve/update requests through HTTP. 117 | #' 118 | #' @param bandit a bayesBandit object 119 | #' @param port port to deploy on 120 | #' @return An active \code{http} process on some port. 121 | #' 122 | #' @details \code{deployBandit} turns a Bayesian bandit into a JSON API that accepts curl requests. Two of the five methods of 123 | #' bayesBandit classes are exposed: \code{serveRecipe} and \code{setResults}. Assuming the API is deployed on \code{localhost} this is an 124 | #' example of how it would be hit: 125 | #' 126 | #' \deqn{curl http://localhost:8000/serveRecipe} 127 | #' 128 | #' \deqn{curl --data '{"A":[1, 0, 1, 1], "B":[0, 0, 0, 1]}' http://localhost:8000/setResults} 129 | #' 130 | #' @examples 131 | #' A_binom <- rbinom(100, 1, .5) 132 | #' B_binom <- rbinom(100, 1, .6) 133 | #' 134 | #' AB1 <- bayesTest(A_binom, B_binom, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 135 | #' 136 | #' binomialBandit <- banditize(AB1) 137 | #' \dontrun{deployBandit(binomialBandit)} 138 | #' 139 | #' @export 140 | deployBandit <- function(bandit, port = 8000) { 141 | if(!requireNamespace("plumber", quietly = TRUE)) { 142 | stop('plumber (>= 0.3.0) is required for this function to work!') 143 | } 144 | # Create a new router 145 | router <- plumber::plumber$new() 146 | 147 | serve <- expression( 148 | function(){ 149 | bandit$serveRecipe() 150 | } 151 | ) 152 | 153 | set <- expression( 154 | function(A = NULL, B = NULL){ 155 | results <- list("A" = A, "B" = B) 156 | bandit$setResults(results) 157 | } 158 | ) 159 | 160 | router$addEndpoint(verbs = "GET", path = "/serveRecipe", 161 | expr = serve) 162 | 163 | router$addEndpoint(verbs = "POST", path = "/setResults", 164 | expr = set) 165 | 166 | router$run(port = port) 167 | 168 | } 169 | -------------------------------------------------------------------------------- /docs/reference/rename.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Rename the posterior for a bayesTest object — rename • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 121 | 122 | 123 | 124 |
    125 | 126 |
    127 |
    128 | 133 | 134 |
    135 |

    Rename the posterior param for a bayesTest object.

    136 |
    137 | 138 |
    rename(bT, newName)
    139 | 140 |

    Arguments

    141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 |
    bT

    a bayesTest object

    newName

    the new name you want for the posterior param (string)

    152 | 153 |

    Value

    154 | 155 |

    a bayesTest object with the posterior parameter renamed

    156 |

    See also

    157 | 158 | 159 | 160 |
    161 | 166 |
    167 | 168 | 169 |
    170 | 173 | 174 |
    175 |

    Site built with pkgdown 1.6.1.

    176 |
    177 | 178 |
    179 |
    180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /docs/reference/grab.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Grab the supplied posterior from a bayesTest object — grab • bayesAB 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
    63 |
    64 | 121 | 122 | 123 | 124 |
    125 | 126 |
    127 |
    128 | 133 | 134 |
    135 |

    Grab the supplied posterior from a bayesTest object, returning another bayesTest object.

    136 |
    137 | 138 |
    grab(bT, posterior)
    139 | 140 |

    Arguments

    141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 |
    bT

    a bayesTest object

    posterior

    the name of a posterior in that object (string)

    152 | 153 |

    Value

    154 | 155 |

    a bayesTest object with the posterior parameter isolated

    156 |

    See also

    157 | 158 | 159 | 160 |
    161 | 166 |
    167 | 168 | 169 | 179 |
    180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /vignettes/extra/priors.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Priors and Bayesian AB Testing" 3 | author: "Frank Portman - fportman.com - frank1214@gmail.com" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Priors and Bayesian AB Testing} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | %\VignetteDepends{magrittr} 11 | --- 12 | 13 | ```{r global_options, include=FALSE} 14 | knitr::opts_chunk$set(fig.path='priors_blog/', warning=FALSE, message=FALSE, fig.width=7.3, fig.show='asis', fig.align='center') 15 | ``` 16 | 17 | ## Why should we care about priors? 18 | 19 | Most questions I've gotten since I released bayesAB have been along the lines of: 20 | 21 | * Why/how is Bayesian AB testing better than Frequentist hypothesis AB testing? 22 | * Why do I need priors? 23 | * Do I really really really need priors? 24 | * How do I choose priors? 25 | 26 | Question 1 has a few objective and a few subjective answers to it. The main benefits are ones that I've already highlighted in the README/vignette of the bayesAB package. To briefly summarize, we get direct probabilities for A > B (rather than p-values) and distributions over the parameter estimates rather than point estimates. Finally, we can also leverage **priors** which help with the low sample size and low base rate problems. 27 | 28 | To start, let's go back to what a **prior** actually is in a Bayesian context. There are countless mathematical resources out there (including part of my previous blog post) so I'll only about this conceptually. Simply put, a **prior** lets you specify some sort of, ahem, *prior* information about a certain parameter so that the end **posterior** on that parameter encapsualtes both the **data** you saw and the **prior** you inputted. Priors can come from a variety of places including past experiments, literature, and domain expertise into the problem. [See this blogpost](http://www.sumsar.net/blog/2015/11/a-bayesian-model-to-calculate-whether-my-wife-is-pregnant/) for a great example of somebody combining their own past data and literature to form very strong priors. 29 | 30 | **Priors** can be weak or strong. The weakest prior will be completely **objective** and thus assign an equal probability to each value for the parameter. Examples of this include a Beta(1, 1) prior for the Bernoulli distribution. In these cases, the **posterior** distribution is completely reliant on the **data**. A strong **prior** will convey a very precise belief as to where a parameter's values may lie. For example: 31 | 32 | ```{r strong_priors} 33 | library(bayesAB) 34 | 35 | plotBeta(1000, 1000) 36 | 37 | ``` 38 | 39 | The stronger the **prior** the more say it has in the **posterior** distribution. Of course, according to the [Bernstein–von Mises theorem](https://en.wikipedia.org/wiki/Bernstein%E2%80%93von_Mises_theorem) the **posterior** is effectively independent of the **prior** once a large enough sample size has been reached for the **data**. How quickly this is the case, depends on the strength of your **prior**. 40 | 41 | Do you need (weak/strong) **priors**? Not necessarily. You can still leverage the interpretability benefits of Bayesian AB testing even without priors. At worst, you'll also get slightly more pertinent results since you can parametrize your metrics as the appropriate distribution random variable. However, without **priors** of some kind (and to be clear, not random bullshit priors either) you run into similar issues as with Frequentist AB testing, namely Type 1 and Type 2 errors. A Type 1 error is calling one version better when it really isn't, and a Type 2 error is calling a better version equal or worse. Both typically arise from low sample size/base rate and are controlled by reaching appropriate sample size as per a [power calculation](https://en.wikipedia.org/wiki/Statistical_power). 42 | 43 | ### So what can we do? 44 | 45 | Have no fear! Even without good and/or strong **priors** there are still ways to control for false positives and all that good stuff. We use something called **Expected Posterior Loss** or "based on the current winner, what is the expected loss you would see should you choose wrongly". If this value is lower than your **threshold of caring** (`abs(A - b)`) then you can go ahead and call your test. This value implictly encompasses the uncertainty about your **posteriors**. 46 | 47 | Okay cool, that roughly answers Questions 1-4 in some order. 48 | 49 | ## Simulation 50 | 51 | Let's do a quick simulation to illustrate some of the above points. Let's make three examples: weak priors, strong priors, and diffuse priors (quick tip: the [Jeffrey's Prior](https://en.wikipedia.org/wiki/Jeffreys_prior) of a Gamma distribution is Gamma(eps, eps) where eps is smallllll). We'll be taking 2 x 100 samples from a Poisson distribution with the same $\lambda$ parameters. The strong and weak priors will be centered around this value of 2.3. 52 | 53 | ```{r simul} 54 | library(magrittr) 55 | 56 | n <- 1e3 57 | out_weaker_priors <- rep(NA, n) 58 | out_stronger_priors <- rep(NA, n) 59 | out_diffuse <- rep(NA, n) 60 | 61 | getProb <- function(x) summary(x)$probability$Lambda 62 | 63 | for(i in 1:n) { 64 | A <- rpois(100, 2.3) 65 | B <- rpois(100, 2.3) 66 | 67 | out_weaker_priors[i] <- bayesTest(A, B, priors = c('shape' = 23, 'rate' = 10), distribution = 'poisson') %>% 68 | getProb 69 | 70 | out_stronger_priors[i] <- bayesTest(A, B, priors = c('shape' = 230, 'rate' = 100), distribution = 'poisson') %>% 71 | getProb 72 | 73 | out_diffuse[i] <- bayesTest(A, B, priors = c('shape' = 0.00001, 'rate' = 0.00001), distribution = 'poisson') %>% 74 | getProb 75 | } 76 | 77 | out_weaker_priors <- ifelse(out_weaker_priors <= 0.05 | out_weaker_priors >= .95, 1, 0) 78 | out_stronger_priors <- ifelse(out_stronger_priors <= 0.05 | out_stronger_priors >= .95, 1, 0) 79 | out_diffuse <- ifelse(out_diffuse <= 0.05 | out_diffuse >= .95, 1, 0) 80 | 81 | ``` 82 | 83 | Now, A and B shouldn't have any difference between the two but occasionally we will see a Type 1 error. That's what the bottom 3 lines are doing. If P(A > B) is <=0.05 or >= .95 we call one of the recipes "significantly" better. Observe what happens with each case of prior. 84 | 85 | ```{r res} 86 | mean(out_weaker_priors) 87 | mean(out_stronger_priors) 88 | mean(out_diffuse) 89 | 90 | ``` 91 | 92 | The diffuse priors have the most Type 1 errors, followed by the weak priors, followed by the strong priors; to be expected. 93 | 94 | Finally, we can fit another bayesTest (:D) to determine whether the differences between Type 1 error percents across priors are different from one another. 95 | 96 | ```{r bern} 97 | t1 <- bayesTest(out_diffuse, out_weaker_priors, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 98 | t2 <- bayesTest(out_diffuse, out_stronger_priors, priors = c('alpha' = 1, 'beta' = 1), distribution = 'bernoulli') 99 | 100 | plot(t1) 101 | 102 | plot(t2, priors = FALSE) 103 | 104 | ``` 105 | 106 | As we can see, it's somewhat clear that the diffuse is worse than the weak and very clear that the diffuse is worse than the stronger priors. Note that in our case I use a diffuse prior of Beta(1, 1) since I have no idea what's normal going into this simulation. 107 | 108 | Finally we can check the output of `summary` to see if the **Posterior Expected Loss** is within our constraints. 109 | 110 | ```{r pel} 111 | summary(t1) 112 | summary(t2) 113 | 114 | ``` 115 | 116 | If the **Posterior Expected Loss** is lower than our threshold for caring on abs(A - B) then we can call this test and accept the current results. The PEL is small in both cases, and possibly 0/NaN for `t2` so it's quite clear that priors, even weak ones, have a significant positive effect on Type 1 Errors. Remember that we see this effect partially because our **priors** were of a similar shape to the **data**. If the **priors** and the **data** disagree, the effects might not be so clear cut and you will need more **data** to have a stable **posterior**. 117 | 118 | --------------------------------------------------------------------------------