robyn_run: Robyn Modelling Function

View source: R/model.R

robyn_runR Documentation

Robyn Modelling Function

Description

robyn_run() consumes robyn_input() outputs, runs robyn_mmm(), and collects all modeling results.

Usage

robyn_run(
  InputCollect = NULL,
  dt_hyper_fixed = NULL,
  json_file = NULL,
  ts_validation = FALSE,
  add_penalty_factor = FALSE,
  refresh = FALSE,
  seed = 123L,
  quiet = FALSE,
  cores = NULL,
  trials = 5,
  iterations = 2000,
  rssd_zero_penalty = TRUE,
  objective_weights = NULL,
  nevergrad_algo = "TwoPointsDE",
  intercept = TRUE,
  intercept_sign = "non_negative",
  lambda_control = NULL,
  outputs = FALSE,
  ...
)

## S3 method for class 'robyn_models'
print(x, ...)

Arguments

InputCollect

List. Contains all input parameters for the model. Required when robyn_object is not provided.

dt_hyper_fixed

data.frame or named list. Only provide when loading old model results. It consumes hyperparameters from saved csv pareto_hyperparameters.csv or JSON file to replicate a model.

json_file

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.

ts_validation

Boolean. When set to TRUE, Robyn will split data by test, train, and validation partitions to validate the time series. By default the "train_size" range is set to c(0.5, 0.8), but it can be customized or set to a fixed value using the hyperparameters input. For example, if train_size = 0.7, validation size and test size will both be 0.15 and 0.15. When ts_validation = FALSE, nrmse_train is the objective function; when ts_validation = TRUE, nrmse_val is the objective function.

add_penalty_factor

Boolean. Add penalty factor hyperparameters to glmnet's penalty.factor to be optimized by nevergrad. Use with caution, because this feature might add too much hyperparameter space and probably requires more iterations to converge.

refresh

Boolean. Set to TRUE when used in robyn_refresh().

seed

Integer. For reproducible results when running nevergrad.

quiet

Boolean. Keep messages off?

cores

Integer. Default to parallel::detectCores() - 1 (all cores except one). Set to 1 if you want to turn parallel computing off.

trials

Integer. Recommended 5 for default nevergrad_algo = "TwoPointsDE".

iterations

Integer. Recommended 2000 for default when using nevergrad_algo = "TwoPointsDE".

rssd_zero_penalty

Boolean. When TRUE, the objective function DECOMP.RSSD will penalize models with more 0 media effects additionally. In other words, given the same DECOMP.RSSD score, a model with 50% 0-coef variables will get penalized by DECOMP.RSSD * 1.5 (larger error), while another model with no 0-coef variables gets un-penalized with DECOMP.RSSD * 1.

objective_weights

Numeric vector. Default to NULL to give equal weights to all objective functions. Order: NRMSE, DECOMP.RSSD, MAPE (when calibration data is provided). When you are not calibrating, only the first 2 values for objective_weights must be defined, i.e. set c(2, 1) to give double weight to the 1st (NRMSE). This is an experimental feature. There's no research on optimal weight setting. Subjective weights might strongly bias modeling results.

nevergrad_algo

Character. Default to "TwoPointsDE". Options are c("DE","TwoPointsDE", "OnePlusOne", "DoubleFastGADiscreteOnePlusOne", "DiscreteOnePlusOne", "PortfolioDiscreteOnePlusOne", "NaiveTBPSA", "cGA", "RandomSearch").

intercept

Boolean. Should intercept(s) be fitted (default=TRUE) or set to zero (FALSE).

intercept_sign

Character. Choose one of "non_negative" (default) or "unconstrained". By default, if intercept is negative, Robyn will drop intercept and refit the model. Consider changing intercept_sign to "unconstrained" when there are context_vars with large positive values.

lambda_control

Deprecated in v3.6.0.

outputs

Boolean. If set to TRUE, will run robyn_run() and robyn_outputs(), returning a list with OutputModels and OutputCollect results.

...

Additional parameters passed to robyn_outputs().

x

robyn_models() output.

Value

List. Class: robyn_models. Contains the results of all trials and iterations modeled.

List. Contains all trained models. Class: robyn_models.

Examples

## Not run: 
# Having InputCollect results
OutputModels <- robyn_run(
  InputCollect = InputCollect,
  cores = 2,
  iterations = 200,
  trials = 1
)

## End(Not run)

Robyn documentation built on June 27, 2024, 9:06 a.m.