robyn_allocator()
function returns a new split of media
variable spends that maximizes the total media response.
robyn_allocator(
robyn_object = NULL,
select_build = 0,
InputCollect = NULL,
OutputCollect = NULL,
select_model = NULL,
json_file = NULL,
scenario = "max_response",
total_budget = NULL,
target_value = NULL,
date_range = "all",
channel_constr_low = NULL,
channel_constr_up = NULL,
channel_constr_multiplier = 3,
optim_algo = "SLSQP_AUGLAG",
maxeval = 1e+05,
constr_mode = "eq",
plots = TRUE,
plot_folder = NULL,
plot_folder_sub = NULL,
export = TRUE,
quiet = FALSE,
ui = FALSE,
...
)# S3 method for robyn_allocator
print(x, ...)
# S3 method for robyn_allocator
plot(x, ...)
A list object containing allocator result.
List. Contains optimized allocation results and plots.
Character or List. Path of the Robyn.RDS
object
that contains all previous modeling information or the imported list.
Integer. Default to the latest model build. select_build = 0
selects the initial model. select_build = 1
selects the first refresh model.
List. Contains all input parameters for the model.
Required when robyn_object
is not provided.
List. Containing all model result.
Required when robyn_object
is not provided.
Character. A model SolID
. When robyn_object
is provided, select_model
defaults to the already selected SolID
. When
robyn_object
is not provided, select_model
must be provided with
InputCollect
and OutputCollect
, and must be one of
OutputCollect$allSolutions
.
Character. JSON file to import previously exported inputs or
recreate a model. To generate this file, use robyn_write()
.
If you didn't export your data in the json file as "raw_data",
dt_input
must be provided; dt_holidays
input is optional.
Character. Accepted options are: "max_response"
, "target_efficiency"
.
Scenario "max_response"
answers the question:
"What's the potential revenue/conversions lift with the same (or custom) spend level
in date_range
and what is the allocation and expected response mix?"
Scenario "target_efficiency"
optimizes ROAS or CPA and answers the question:
"What's the potential revenue/conversions lift and spend levels based on a
target_value
for CPA/ROAS and what is the allocation and expected response mix?"
Deprecated scenario: "max_response_expected_spend"
.
Numeric. Total marketing budget for all paid channels for the
period in date_range
.
Numeric. When using the scenario "target_efficiency"
,
target_value is the desired ROAS or CPA with no upper spend limit. Default is set to 80% of
initial ROAS or 120% of initial CPA, when "target_value = NULL"
.
Character. Date(s) to apply adstocked transformations and pick mean spends
per channel. Set one of: "all", "last", or "last_n" (where
n is the last N dates available), date (i.e. "2022-03-27"), or date range
(i.e. c("2022-01-01", "2022-12-31")
). Default to "all".
Numeric vectors. The lower and upper bounds
for each paid media variable when maximizing total media response. For example,
channel_constr_low = 0.7
means minimum spend of the variable is 70
average, using non-zero spend values, within date_min
and date_max
date range.
Both constrains must be length 1 (same for all values) OR same length and order as
paid_media_spends
. It's not recommended to 'exaggerate' upper bounds, especially
if the new level is way higher than historical level. Lower bound must be >=0.01,
and upper bound should be < 5.
Numeric. Default to 3. For example, if
channel_constr_low
and channel_constr_up
are 0.8 to 1.2, the range is 0.4.
The allocator will also show the optimum solution for a larger constraint range of
0.4 x 3 = 1.2, or 0.4 to 1.6, to show the optimization potential to support allocation
interpretation and decision.
Character. Default to "SLSQP_AUGLAG"
, short for "Sequential Least-Squares
Quadratic Programming" and "Augmented Lagrangian". Alternatively, ""MMA_AUGLAG"
,
short for "Methods of Moving Asymptotes". More details see the documentation of
NLopt here.
Integer. The maximum iteration of the global optimization algorithm. Defaults to 100000.
Character. Options are "eq"
or "ineq"
,
indicating constraints with equality or inequality.
Boolean. Generate plots?
Character. Path for saving plots and files. Default
to robyn_object
and saves plot in the same directory as robyn_object
.
Character. Sub path for saving plots. Will overwrite the default path with timestamp or, for refresh and allocator, simply overwrite files.
Boolean. Export outcomes into local files?
Boolean. Keep messages off?
Boolean. Save additional outputs for UI usage. List outcome.
Additional parameters passed to robyn_outputs()
.
robyn_allocator()
output.
if (FALSE) {
# Having InputCollect and OutputCollect results
AllocatorCollect <- robyn_allocator(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = "1_2_3",
scenario = "max_response",
channel_constr_low = 0.7,
channel_constr_up = c(1.2, 1.5, 1.5, 1.5, 1.5),
channel_constr_multiplier = 4,
date_range = "last_26",
export = FALSE
)
# Print a summary
print(AllocatorCollect)
# Plot the allocator one-pager
plot(AllocatorCollect)
}
Run the code above in your browser using DataLab