robyn_response | R Documentation |
robyn_response()
returns the response for a given
spend level of a given paid_media_vars
from a selected model
result and selected model build (initial model, refresh model, etc.).
robyn_response(
InputCollect = NULL,
OutputCollect = NULL,
json_file = NULL,
robyn_object = NULL,
select_build = NULL,
select_model = NULL,
metric_name = NULL,
metric_value = NULL,
date_range = NULL,
dt_hyppar = NULL,
dt_coef = NULL,
quiet = FALSE,
...
)
InputCollect |
List. Contains all input parameters for the model.
Required when |
OutputCollect |
List. Containing all model result.
Required when |
json_file |
Character. JSON file to import previously exported inputs or
recreate a model. To generate this file, use |
robyn_object |
Character or List. Path of the |
select_build |
Integer. Default to the latest model build. |
select_model |
Character. A model |
metric_name |
A character. Selected media variable for the response. Must be one value from paid_media_spends, paid_media_vars or organic_vars |
metric_value |
Numeric. Desired metric value to return a response for. |
date_range |
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. |
dt_hyppar |
A data.frame. When |
dt_coef |
A data.frame. When |
quiet |
Boolean. Keep messages off? |
... |
Additional parameters passed to |
List. Response value and plot. Class: robyn_response
.
## Not run:
# Having InputCollect and OutputCollect objects
## Recreate original saturation curve
Response <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "facebook_S"
)
Response$plot
## Or you can call a JSON file directly (a bit slower)
# Response <- robyn_response(
# json_file = "your_json_path.json",
# dt_input = dt_simulated_weekly,
# dt_holidays = dt_prophet_holidays,
# metric_name = "facebook_S"
# )
## Get the "next 100 dollar" marginal response on Spend1
Spend1 <- 20000
Response1 <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "facebook_S",
metric_value = Spend1, # total budget for date_range
date_range = "last_1" # last two periods
)
Response1$plot
Spend2 <- Spend1 + 100
Response2 <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "facebook_S",
metric_value = Spend2,
date_range = "last_1"
)
# ROAS for the 100$ from Spend1 level
(Response2$response_total - Response1$response_total) / (Spend2 - Spend1)
## Get response from for a given budget and date_range
Spend3 <- 100000
Response3 <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "facebook_S",
metric_value = Spend3, # total budget for date_range
date_range = "last_5" # last 5 periods
)
Response3$plot
## Example of getting paid media exposure response curves
imps <- 10000000
response_imps <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "facebook_I",
metric_value = imps
)
response_imps$response_total / imps * 1000
response_imps$plot
## Example of getting organic media exposure response curves
sendings <- 30000
response_sending <- robyn_response(
InputCollect = InputCollect,
OutputCollect = OutputCollect,
select_model = select_model,
metric_name = "newsletter",
metric_value = sendings
)
# response per 1000 sendings
response_sending$response_total / sendings * 1000
response_sending$plot
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.