-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrobyn_allocator_example.R
39 lines (31 loc) · 1.02 KB
/
robyn_allocator_example.R
1
2
3
4
5
6
7
8
9
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
# user input
#
# plan spend for next 365 days
tv_plan_spend = 5000000
fb_plan_spend = 2000000
#
# Read in rds which was saved by robyn_save() and has an embedded selected model
#
plot_folder = 'e:/repo/robyn-mmm/output'
filename = paste0(plot_folder,"/","mmm_2022_02_22.RDS")
tv_hist_spend = 1810935
fb_hist_spend = 1797576
#
# derive values
#
total_plan_spend = tv_plan_spend + fb_plan_spend
compute_target = c(tv_plan_spend / tv_hist_spend, fb_plan_spend/fb_hist_spend)
print(compute_target)
expected_optm_spend_unit_delta = c(tv_plan_spend / tv_hist_spend - 1, fb_plan_spend/fb_hist_spend - 1)
print(paste('Expected optm spend unit delta in ouptut', expected_optm_spend_unit_delta))
#
# Invoke allocator with min and max constraining optimizer; generates csv and png file
#
AllocatorCollect <- robyn_allocator(
robyn_object = filename,
scenario = "max_response_expected_spend",
channel_constr_low = compute_target,
channel_constr_up = compute_target,
expected_spend = total_plan_spend,
expected_spend_days = 365
)