robyn_inputs | R Documentation |
robyn_inputs()
is the function to input all model parameters and
check input correctness for the initial model build. It includes the
engineering process results that conducts trend, season,
holiday & weekday decomposition using Facebook's time-series forecasting
library prophet
and fit a nonlinear model to spend and exposure
metrics in case exposure metrics are used in paid_media_vars
.
robyn_inputs(
dt_input = NULL,
dep_var = NULL,
dep_var_type = NULL,
date_var = "auto",
paid_media_spends = NULL,
paid_media_vars = NULL,
paid_media_signs = NULL,
organic_vars = NULL,
organic_signs = NULL,
context_vars = NULL,
context_signs = NULL,
factor_vars = NULL,
dt_holidays = Robyn::dt_prophet_holidays,
prophet_vars = NULL,
prophet_signs = NULL,
prophet_country = NULL,
adstock = NULL,
hyperparameters = NULL,
window_start = NULL,
window_end = NULL,
calibration_input = NULL,
json_file = NULL,
InputCollect = NULL,
...
)
## S3 method for class 'robyn_inputs'
print(x, ...)
dt_input |
data.frame. Raw input data. Load simulated
dataset using |
dep_var |
Character. Name of dependent variable. Only one allowed |
dep_var_type |
Character. Type of dependent variable as "revenue" or "conversion". Will be used to calculate ROI or CPI, respectively. Only one allowed and case sensitive. |
date_var |
Character. Name of date variable. Daily, weekly
and monthly data supported.
|
paid_media_spends |
Character vector. Names of the paid media variables.
The values on each of these variables must be numeric. Also,
|
paid_media_vars |
Character vector. Names of the paid media variables'
exposure level metrics (impressions, clicks, GRP etc) other than spend.
The values on each of these variables must be numeric. These variables are not
being used to train the model but to check relationship and recommend to
split media channels into sub-channels (e.g. fb_retargeting, fb_prospecting,
etc.) to gain more variance. |
paid_media_signs |
Character vector. Choose any of
|
organic_vars |
Character vector. Typically newsletter sendings,
push-notifications, social media posts etc. Compared to |
organic_signs |
Character vector. Choose any of
"default", "positive", "negative". Control
the signs of coefficients for |
context_vars |
Character vector. Typically competitors, price & promotion, temperature, unemployment rate, etc. |
context_signs |
Character vector. Choose any of
|
factor_vars |
Character vector. Specify which of the provided variables in organic_vars or context_vars should be forced as a factor. |
dt_holidays |
data.frame. Raw input holiday data. Load standard
Prophet holidays using |
prophet_vars |
Character vector. Include any of "trend", "season", "weekday", "monthly", "holiday" or NULL. Highly recommended to use all for daily data and "trend", "season", "holiday" for weekly and above cadence. Set to NULL to skip prophet's functionality. |
prophet_signs |
Character vector. Choose any of
"default", "positive", "negative". Control
the signs of coefficients for |
prophet_country |
Character. Only one country allowed.
Includes national holidays for all countries, whose list can
be found loading |
adstock |
Character. Choose any of "geometric", "weibull_cdf",
"weibull_pdf". Weibull adstock is a two-parametric function and thus more
flexible, but takes longer time than the traditional geometric one-parametric
function. CDF, or cumulative density function of the Weibull function allows
changing decay rate over time in both C and S shape, while the peak value will
always stay at the first period, meaning no lagged effect. PDF, or the
probability density function, enables peak value occurring after the first
period when shape >=1, allowing lagged effect. Run |
hyperparameters |
List. Contains hyperparameter lower and upper bounds.
Names of elements in list must be identical to output of |
window_start , window_end |
Character. Set start and end dates of modelling
period. Recommended to not start in the first date in dataset to gain adstock
effect from previous periods. Also, columns to rows ratio in the input data
to be >=10:1, or in other words at least 10 observations to 1 independent variable.
This window will determine the date range of the data period within your dataset
you will be using to specifically regress the effects of media, organic and
context variables on your dependent variable. We recommend using a full
|
calibration_input |
data.frame. Optional. Provide experimental results to calibrate. Your input should include the following values for each experiment: channel, liftStartDate, liftEndDate, liftAbs, spend, confidence, metric. You can calibrate any spend or organic variable with a well designed experiment. You can also use experimental results from multiple channels; to do so, provide concatenated channel value, i.e. "channel_A+channel_B". Check "Guide for calibration source" section. |
json_file |
Character. JSON file to import previously exported inputs or
recreate a model. To generate this file, use |
InputCollect |
Default to NULL. |
... |
Additional parameters passed to |
x |
|
List. Contains all input parameters and modified results
using Robyn:::robyn_engineering()
. This list is ready to be
used on other functions like robyn_run()
and print()
.
Class: robyn_inputs
.
We strongly recommend to use experimental and causal results that are considered ground truth to calibrate MMM. Usual experiment types are people-based (e.g. Facebook conversion lift) and geo-based (e.g. Facebook GeoLift).
Currently, Robyn only accepts point-estimate as calibration input. For example, if 10k$ spend is tested against a hold-out for channel A, then input the incremental return as point-estimate as the example below.
The point-estimate has to always match the spend in the variable. For example, if channel A usually has 100k$ weekly spend and the experimental HO is 70
# Using dummy simulated data
InputCollect <- robyn_inputs(
dt_input = Robyn::dt_simulated_weekly,
dt_holidays = Robyn::dt_prophet_holidays,
date_var = "DATE",
dep_var = "revenue",
dep_var_type = "revenue",
prophet_vars = c("trend", "season", "holiday"),
prophet_country = "DE",
context_vars = c("competitor_sales_B", "events"),
paid_media_spends = c("tv_S", "ooh_S", "print_S", "facebook_S", "search_S"),
paid_media_vars = c("tv_S", "ooh_S", "print_S", "facebook_I", "search_clicks_P"),
organic_vars = "newsletter",
factor_vars = "events",
window_start = "2016-11-23",
window_end = "2018-08-22",
adstock = "geometric",
# To be defined separately
hyperparameters = NULL,
calibration_input = NULL
)
print(InputCollect)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.