sample_cpa {grizbayr} | R Documentation |
Sample Cost Per Activation (CPA)
Description
Adds 3 new nested columns to the input_df: 'beta_params', 'gamma_params', and 'samples'
'beta_params' and 'gamma_params' in each row should be a tibble of length 2 (\alpha
and \beta
parameters and k
and \theta
parameters)
'samples' in each row should be a tibble of length 'n_samples'
Usage
sample_cpa(input_df, priors, n_samples = 50000)
Arguments
input_df |
Dataframe containing option_name (str), sum_conversions (dbl), sum_cost (dbl), and sum_clicks (dbl). |
priors |
Optional list of priors alpha0, beta0 for Beta and k0, theta0
for Gamma.
Default |
n_samples |
Optional integer value. Defaults to 50,000 samples. |
Details
See update_rules vignette for a mathematical representation. This is a combination of a Beta-Bernoulli update and a Gamma-Exponential update.
conversion_i ~ Bernoulli(\phi)
cpc_i ~ Exponential(\lambda)
\phi ~ Beta(\alpha, \beta)
\lambda ~ Gamma(k, \theta)
cpa_i ~ 1/ (Bernoulli(\phi) * Exponential(\lambda))
averageCPA ~ 1/(\phi\lambda)
Conversion Rate is sampled from a Beta distribution with a Binomial likelihood of an individual converting.
Average CPC is sampled from a Gamma distribution with an Exponential likelihood of an individual cost.
Value
input_df with 3 new nested columns 'beta_params', 'gamma_params', and 'samples'