Learn R Programming

⚠️There's a newer version (1.3.5) of this package.Take me there.

grizbayr

A Bayesian Inference Package for A|B and Bandit Marketing Tests

Description:

Uses simple Bayesian conjugate prior update rules to calculate the following metrics for various marketing objectives:

  1. Win Probability of each option
  2. Value Remaining in the Test
  3. Percent Lift Over the Baseline

This allows a user to implement Bayesian Inference methods when analyzing the results of a split test or Bandit experiment.

Examples

See the intro vignette for examples to get started.

Marketing objectives supported:

  • Conversion Rate
  • Response Rate
  • Click Through Rate (CTR)
  • Revenue Per Session
  • Multi Revenue Per Session
  • Cost Per Activation (CPA)
  • Total Contribution Margin (CM)
  • CM Per Click
  • Cost Per Click (CPC)

Contributing

New Posterior Distributions

To add a new posterior distribution you must complete the following:

  1. Create a new function called sample_...(input_df, priors, n_samples). Use the internal helper functions update_gamma, update_beta, etc. included in this package or you can create a new one.
  2. This function (and the name) must be added to the switch statement in sample_from_posterior()
  3. A new row must be added to the internal data object distribution_column_mapping.
    • Select this object from the package
    • Add a new row with a 1 for every column that is required for this distribution (this is for data validation and clear alerting for the end user)
    • Save the updated tibble object using use_data(new_tibble, internal = TRUE, overwrite = TRUE) and it will be saved as sysdata.rda in the package for internal use.
    • Update the start.Rmd markdown table to include which columns are required for your function.
  4. Create a PR for review.

New Features Ideas (TODO)

  • High Density Credible Intervals with each option
  • Conjugate Prior Update Rules vignette deriving each marketing objective update_rules

Package Name

The name is a play on Bayes with an added r (bayesr). The added griz (or Grizzly Bear) creates a unique name that is searchable due to too many similarly named packages.

Copy Link

Version

Install

install.packages('grizbayr')

Monthly Downloads

315

Version

1.2.3

License

MIT + file LICENSE

Maintainer

Ryan Angi

Last Published

July 7th, 2020

Functions in grizbayr (1.2.3)

estimate_lift

Estimate Lift Distribution
estimate_win_prob

Estimate Win Probability
calculate_total_cm

Calculate Total CM
estimate_loss

Estimate Loss
calculate_multi_rev_per_session

Calculate Multi Rev Per Session
estimate_value_remaining

Estimate Value Remaining
estimate_all_values

Estimate All Values
estimate_win_prob_given_posterior

Estimate Win Probability Given Posterior Distribution
estimate_lift_vs_baseline

Estimate Lift vs Baseline
estimate_win_prob_vs_baseline

Estimate Win Probability vs. Baseline
sample_conv_rate

Sample Conversion Rate
sample_cpa

Sample Cost Per Activation (CPA)
estimate_win_prob_vs_baseline_given_posterior

Estimate Win Probability vs. Baseline Given Posterior
impute_missing_options

Impute Missing Options
grizbayr

grizbayr package
sample_from_posterior

Sample From Posterior
sample_cm_per_click

Sample CM Per Click
sample_ctr

Sample Click Through Rate
rdirichlet

Random Dirichlet
sample_cpc

Sample Cost Per Click
validate_data_values

Validate Data Values
sample_multi_rev_per_session

Sample Multiple Revenue Per Session
find_best_option

Find Best Option
update_dirichlet

Update Dirichlet Distribution
update_beta

Update Beta
sample_total_cm

Sample Total CM (Given Impression Count)
validate_input_column

Validate Input Column
update_gamma

Update Gamma
validate_priors

Validate Priors
validate_posterior_samples

Validate Posterior Samples Dataframe
validate_input_df

Validate Input DataFrame
is_prior_valid

Is Prior Valid
sample_response_rate

Sample Response Rate
is_winner_max

Is Winner Max
sample_rev_per_session

Sample Rev Per Session
validate_wrt_option

Validate With Respect To Option