Robyn is one of the most capable open-source tools available for Marketing Mix Modelling, and it’s genuinely accessible to analysts with moderate R familiarity — provided you know what you’re walking into. This guide walks you through an actual Robyn setup: what you need before you start, how to format your data, how to run your first model, and how to interpret the main outputs.

This is a practical walkthrough written for analysts who have used R before but haven’t configured an MMM model. It’s honest about the complexity, covers the most common errors, and tells you when to stop and consider an alternative path.

In this guide, you’ll find environment prerequisites, data formatting requirements, a script walkthrough for your first model run, guidance on reading the output plots, and a list of the most common errors and their fixes.


Prerequisites: What You Need Before You Start

Before running a single line of code, confirm you have the following in place.

Software Requirements

Software Version Notes
R 4.3.0 or higher Check with R.version in the console
RStudio Any recent version Recommended; not strictly required
Python 3.10–3.12 Required for Nevergrad optimisation
Robyn package Latest from GitHub Install via remotes package

Important: Robyn requires Python for its Nevergrad black-box optimisation engine — the component that searches across thousands of parameter combinations to find the best model fit. If you don’t have Python installed, or if the R-Python bridge fails, Robyn will not complete a model run.

Installation Steps

Run the following in your R console in order:

# Step 1: Install remotes if you don't have it
install.packages("remotes")

# Step 2: Install Robyn from GitHub
remotes::install_github("facebookresearch/Robyn/R@main")

# Step 3: Install Python reticulate bridge
install.packages("reticulate")

# Step 4: Install Nevergrad via Python (run once)
library(reticulate)
py_install("nevergrad", pip = TRUE)

If you encounter errors at Step 4, verify you have Python 3.10–3.12 installed and that R can find it. Run py_config() in the console to check which Python version reticulate is using.


Data Format Requirements

Robyn expects your data in a specific structure. Getting this right before you start will save you significant debugging time.

The Required DataFrame

Your main data input must be a weekly time-series dataset with DATE, your KPI (e.g., REVENUE), and spend columns for each channel. Key formatting rules:

  • DATE column: Must be in Date class format (YYYY-MM-DD). Character strings that look like dates will produce errors.
  • No missing weeks: Robyn requires a continuous weekly series with no gaps. If a channel had zero spend for a week, enter 0 — not NA.
  • Consistent currency: All spend figures must be in the same currency and at the same scale.
  • Minimum history: At least 52 weeks of data is required; 104+ weeks (two years) is strongly recommended.

Converting Your Date Column

If your date column imports as a character string (common when reading from CSV), convert it using:

df$DATE <- as.Date(df$DATE, format = "%Y-%m-%d")

Data Validation Check

Before loading into Robyn, validate your data by checking for date continuity (no weekly gaps) and ensuring there are no NA values in any column. Resolve any date gaps or NA values before proceeding.


Running Your First Model: A Script Walkthrough

Here is a stripped-down but complete Robyn configuration for a first model run. Adapt the variable names and column names to match your dataset.

Step 1: Load Robyn and Set Your Data

Use robyn_inputs() to connect Robyn to your dataframe. You’ll specify your date variable, your dependent variable (revenue), and which columns represent paid media spend and external context variables (e.g., promotions, holidays). Set your modelling window using window_start and window_end.

Step 2: Set Hyperparameter Ranges

This is the most configuration-intensive step. Hyperparameters control how Robyn models the Carry-Over Effect and saturation (Diminishing Returns) for each channel. You define a range for each — Nevergrad searches within these ranges to find the best fit.

For each channel, you set:

  • Alphas — saturation curve shape
  • Gammas — saturation speed
  • Thetas — Carry-Over decay rate (0 = no carry-over; 0.8 = long carry-over)

Guidance on theta ranges: For direct-response channels (paid search), use theta ranges up to 0.3. For brand and TV channels, use ranges up to 0.7–0.8.

Step 3: Run the Model

Use robyn_run() with your InputCollect object. Key parameters:

  • cores: Set to the number of cores on your machine
  • iterations: 2,000 for a first run; increase to 5,000+ for a more thorough search
  • trials: Number of independent optimisation runs (5 is a good default)
  • ts_validation: TRUE — recommended to hold out a validation period

This step takes time. For 2,000 iterations across 5 trials, expect 20–60 minutes depending on your hardware.


Reading and Interpreting the Output Plots

Robyn generates several output plots automatically. Here are the key ones and what they tell you.

One-Pager Plot

The main output for each model candidate. Key panels to focus on:

Decomposition Waterfall — shows your revenue broken down into Organic Base, each media channel’s contribution, and seasonality/trend effects. This is your Contribution Breakdown. Read the percentage labels on each bar.

Spend Efficiency Curves — S-shaped curves showing how each channel’s contribution increases with spend. The steeper the curve, the more efficient the channel. The position of your average spend on the curve shows whether you’re below, at, or above the most efficient spend level.

Actual vs. Fitted Line Chart — a time-series showing modelled revenue vs. actual revenue. If these lines track closely (NRMSE below 0.15 is a good target), the model is fitting your data well.

Pareto Front Plot

Robyn returns multiple model candidates on a Pareto front — a set of “equally good” models that balance model fit (NRMSE) against channel decomposition quality (DECOMP.RSSD).

To select a model, use robyn_outputs() with pareto_fronts = “auto” to view all candidate models. Select a model that sits on the Pareto front, has NRMSE below 0.15, and produces decomposition results that pass your sanity checks.


Common Errors and How to Fix Them

Error: Python not found or Nevergrad not available

Cause: R cannot find your Python installation, or Nevergrad was not installed correctly.

Fix: Run py_config() in R to see which Python is being used. If it’s not finding the correct version, specify the path manually using reticulate::use_python(), then reinstall Nevergrad via pip.

Error: DATE must be a Date class

Cause: Your date column is formatted as a character string, not a Date class.

Fix: Convert it with as.Date(df$DATE, format = “%Y-%m-%d”)

Error: Model runs complete but decomposition shows nonsensical results

Cause: Most commonly, hyperparameter ranges are too narrow or key context variables (promotions, seasonality) are missing.

Fix: Widen your theta ranges by 20–30% and confirm that any major promotional or seasonal events are included as context variables.

Error: NA values in spend columns

Cause: Missing data weeks, platform reporting gaps, or Excel cell formatting issues.

Fix: Replace NA values with 0 for weeks where a channel had zero spend. Never leave NA values in your spend columns.


When You’ve Hit Your Limit: Alternatives to Raw Robyn

This walkthrough covers the essentials, but Robyn’s full range of capabilities — calibration against lift tests, refreshed model runs with new data, multi-model comparison across periods — requires deeper R and statistical expertise.

If you’ve worked through this guide and concluded that the ongoing maintenance overhead of running Robyn in R is more than your workflow can absorb, a managed platform gives you the same outputs through a guided interface. You still control your data, your channel configuration, and your outputs — without managing the R environment.

There’s no shame in that choice. Using the right tool for your context is what a competent analyst does.


Frequently Asked Questions

What version of R do I need to run Robyn MMM?

Robyn requires R 4.3.0 or higher. You can check your current version by running R.version in the console. Older versions of R may encounter package compatibility issues, particularly with Robyn’s dependencies.

Do I need to know Python to use Robyn?

You don’t need to write Python code to use Robyn, but you do need Python installed on your machine. Robyn uses Python’s Nevergrad library for hyperparameter optimisation, accessed through R’s reticulate bridge. The most common setup issue is R not finding the correct Python version — running py_config() in R will show you which Python is being used.

How many iterations should I run in Robyn?

For a reliable first model, 2,000 iterations across 5 trials is a reasonable starting point. For a final production model, increasing to 5,000–10,000 iterations will produce a more thorough optimisation. Expect longer runtimes: 2,000 iterations typically takes 20–60 minutes; 10,000 iterations may take several hours.

How do I choose between the models on the Pareto front?

Choose the model closest to the origin of the Pareto plot, then apply your own sanity checks — does the Organic Base look plausible for your business? Do Carry-Over estimates match your knowledge of each channel? The Pareto front balances model fit (NRMSE) against channel decomposition quality (DECOMP.RSSD) — a good selection balances both.

Can I run Robyn on Windows?

Yes, Robyn runs on Windows, but Windows environments are more prone to R-Python compatibility issues than Mac or Linux. The most common problems involve conflicting R package versions and Python environment detection. If you encounter persistent errors, check that R 4.3.0+ is installed, Python 3.10–3.12 is in your system PATH, and the reticulate package can find your Python installation via py_config().


Ready to Try a Faster Path?

If you’ve worked through this guide and want to compare what the same analysis looks like without configuring R, try MMM Pilot’s trial. Upload your spend and revenue data, configure your channels through a guided interface, and see your first Contribution Breakdown — without writing a line of code.

Try MMM Pilot — no R required →

Official Robyn MMM Guide →