---
title: "Marketing mix modeling with Meridian and Robyn"
description: "What MMM is — and is not A marketing mix model (MMM) is a statistical model that explains an outcome (sales, conversions, sign-ups) over time as a…"
url: https://optimizeall.com/learn/ai-performance-marketing/marketing-mix-modelling
updated: 2026-10-05
---

AI-Powered Performance Marketing · Attribution, incrementality and mix modeling · lesson 12 of 15 · 8 min

# Marketing mix modeling with Meridian and Robyn

## What MMM is — and is not

A **marketing mix model (MMM)** is a statistical model that explains an outcome (sales, conversions, sign-ups) over time as a function of marketing spend or exposure by channel, plus non-marketing factors: seasonality, price, promotions, distribution, competitor activity, macro factors. It uses **aggregated data** (weekly by region or national), not user-level tracking, which makes it robust to cookie loss and consent gaps.

MMM answers: *roughly how much did each channel contribute, where are we on each channel's response curve, and how should we split next quarter's budget?* It does **not** optimize daily bids or tell you which ad won.

## Two leading open-source options

| | **Meridian** (Google) | **Robyn** (Meta) |
|---|---|---|
| Language | Python | R (Python port in beta) |
| Approach | Bayesian, hierarchical geo-level modeling | Ridge regression with multi-objective hyperparameter optimization |
| Priors / calibration | ROI priors, can incorporate experiment results as priors | Calibration with lift test results |
| Special features | Reach and frequency inputs, geo hierarchy, budget optimizer | Automated model selection, budget allocator |
| Availability | Generally available since 2025; open source | Actively maintained open source |

Both need good data and judgment. Neither is "plug and play."

## Data you need

- **Outcome**: weekly (or daily) sales or conversions, ideally by region, for **2–3 years** where possible (Google's Meridian guidance discusses data sufficiency; more history and more geos help).
- **Media**: spend and, where possible, impressions or reach per channel per period.
- **Controls**: price, promotions, holidays (Ramadan and Eid shift each year — encode them by actual dates), product launches, stock-outs, organic search trends, macro indicators.
- **Population** per geo for geo-level models.

## Key concepts inside the model

- **Adstock (carryover)**: advertising effects decay over time; TV and YouTube effects linger longer than search.
- **Saturation**: response curves (see the budget lesson).
- **Priors** (Bayesian): what you believe before seeing data — e.g., "ROI of YouTube is likely between 0.5 and 3". Experiment results make excellent priors.
- **Uncertainty**: good MMMs report credible intervals. A channel whose interval spans from harmful to excellent needs an experiment.

## Worked example: a Pakistani FMCG brand

A packaged-food brand in Pakistan spends on TV, YouTube, Meta, TikTok, influencers and trade promotions. They build a Meridian model with weekly sales by province for three years, TV GRPs, digital spend and impressions, promotions, price index and Ramadan/Eid dates. Findings (illustrative): TV and YouTube have long carryover; Meta and TikTok show strong short-term effects with saturation at current spend in Punjab but headroom in Sindh; influencer spend has a wide interval. Actions: shift some digital budget toward Sindh, run a geo test on influencer spend to narrow the interval, and re-run the model quarterly with the test as a prior.

## Hands-on: the Meridian workflow (Python)

The structure below follows Meridian's getting-started pattern. Class and argument names evolve between releases — check the current Meridian documentation before running.

```python
# pip install --upgrade google-meridian
import tensorflow_probability as tfp
from meridian import constants
from meridian.data import load
from meridian.model import model, spec, prior_distribution
from meridian.analysis import optimizer

coord_to_columns = load.CoordToColumns(
    time="week", geo="province", population="population",
    kpi="orders", revenue_per_kpi="avg_order_value",
    controls=["price_index", "promo_flag", "ramadan_flag"],
    media=["tv_grps", "youtube_imps", "meta_imps", "tiktok_imps"],
    media_spend=["tv_spend", "youtube_spend", "meta_spend", "tiktok_spend"],
)
loader = load.CsvDataLoader(
    csv_path="mmm_weekly_by_province.csv", kpi_type="non_revenue",
    coord_to_columns=coord_to_columns,
    media_to_channel={"tv_grps": "TV", "youtube_imps": "YouTube", "meta_imps": "Meta", "tiktok_imps": "TikTok"},
    media_spend_to_channel={"tv_spend": "TV", "youtube_spend": "YouTube", "meta_spend": "Meta", "tiktok_spend": "TikTok"},
)
data = loader.load()

prior = prior_distribution.PriorDistribution(
    roi_m=tfp.distributions.LogNormal(0.2, 0.9, name=constants.ROI_M))
mmm = model.Meridian(input_data=data, model_spec=spec.ModelSpec(prior=prior))
mmm.sample_prior(500)
mmm.sample_posterior(n_chains=4, n_adapt=500, n_burnin=500, n_keep=1000)

opt = optimizer.BudgetOptimizer(mmm)
results = opt.optimize()  # review the suggested reallocation and its uncertainty
```

Check convergence diagnostics (for example R-hat) and model fit before trusting outputs.

## Using AI to help

LLMs are useful for: drafting data dictionaries, writing data-cleaning code, explaining diagnostics, and turning model output into a plain-language memo. They are not a substitute for the model. Never paste confidential sales data into tools your organization has not approved.

## Pitfalls

- Too little variation: if you spent the same every week, the model cannot learn a response.
- Collinearity: channels that always move together cannot be separated — run experiments to break the link.
- Ignoring uncertainty and presenting point estimates as facts.
- Treating MMM as a one-off project instead of a quarterly process.

## How to measure success

Out-of-sample fit, stable results across refreshes, agreement with experiments (calibration), and — above all — budget decisions that improve total business outcomes when tested.

## Video lecture: Marketing mix modeling with Meridian and Robyn

Lecture coming soon · 13 chapters · about 8 minutes. Read the full transcript below.

1. Marketing mix modeling
2. Why it matters
3. What MMM is
4. Meridian vs Robyn
5. Data you need
6. Simple example: adstock (illustrative)
7. Four core concepts
8. Example: Pakistani FMCG (illustrative)
9. Meridian workflow
10. Where AI helps
11. Mistakes + try this now
12. Watch me do it: MMM data prep (illustrative)
13. Recap and next step

## Lecture transcript

### Marketing mix modeling

If cookies and consent banners have made your tracking patchy, there's a measurement method that never needed cookies in the first place. It's been used by big advertisers for decades, and now it's free and open source. It's marketing mix modeling. In this lecture you'll learn what an MMM does and doesn't do, how Google's Meridian and Meta's Robyn compare, what data you need, and how to run a Meridian model at a high level.

### Why it matters

Why does this matter? Because marketing mix modeling is the one method that looks at every channel, online and offline, at once, without tracking a single person. Here's an analogy. Think of trying to work out which ingredients make a cake rise by baking hundreds of cakes over the years with slightly different amounts of flour, eggs and baking powder, and noting how tall each one rose. You never watch a single molecule. You learn from the pattern across many cakes. MMM does the same with weeks of sales and weeks of spend.

### What MMM is

A marketing mix model explains your sales over time as a combination of marketing by channel plus everything else: seasonality, price, promotions, distribution and even the economy. It uses aggregated data, weekly and ideally by region, not individual tracking. That's why it's resilient to cookie loss. It tells you roughly how much each channel contributed and where each one sits on its response curve. What it doesn't do is set daily bids or pick your best ad.

### Meridian vs Robyn

The two leading open-source options are Meridian from Google and Robyn from Meta. Meridian is written in Python and uses Bayesian hierarchical modeling, which means it can model regions and incorporate prior knowledge, such as experiment results. It became generally available in twenty twenty-five. Robyn is written in R, with a Python port in beta, and uses ridge regression with automated model selection. Both are actively maintained. Neither is plug and play.

### Data you need

Now the data. You need your outcome, like weekly sales or orders, ideally by region, for two to three years if possible. You need spend per channel, plus impressions or reach where you have them. And you need controls: price, promotions, product launches, stock-outs, and holidays. A tip for our markets: Ramadan and Eid move every year, so encode them by actual dates, not by calendar month, or the model will blame your ads for Ramadan.

### Simple example: adstock (illustrative)

Here's a simple worked example of carryover, or adstock. Suppose a YouTube campaign runs for one week and lifts sales by one hundred units that week. With an adstock decay of fifty percent, the effect the next week is fifty units, then twenty-five, then about twelve. So the total effect is nearly two hundred units, not one hundred. If you only looked at the week the ads ran, you'd undervalue YouTube by half. Search, by contrast, might have almost no carryover. That's why MMM often shows video and TV performing better than last-click reports suggest.

### Four core concepts

Four concepts make MMM make sense. Adstock, or carryover: an ad's effect decays over time, and TV or YouTube lingers longer than search. Saturation: the diminishing-returns curve. Priors, in Bayesian models: what you believe before seeing the data, like a YouTube return likely between half and three times spend. And uncertainty: good models report ranges. If a channel's range goes from harmful to brilliant, you need an experiment, not a decision.

### Example: Pakistani FMCG (illustrative)

Here's an illustrative example. A packaged-food brand in Pakistan spends on TV, YouTube, Meta, TikTok, influencers and trade promotions. They built a Meridian model with three years of weekly sales by province. TV and YouTube showed long carryover. Meta and TikTok looked saturated in Punjab but had room to grow in Sindh. Influencer spend had a very wide interval. So they shifted some digital budget to Sindh, and scheduled a geo test on influencers to narrow that uncertainty.

### Meridian workflow

The lesson walks through the Meridian workflow in Python. You map your columns, load the data, set a prior on return on investment, sample the posterior, and then run the budget optimizer. Library names change between releases, so check the current documentation. And before you trust any output, check the convergence diagnostics and how well the model fits data it hasn't seen.

### Where AI helps

Where does AI fit? LLMs are great at drafting data dictionaries, writing cleaning code, explaining diagnostics and turning model output into a plain-language memo for leadership. They're not a substitute for the model itself. And never paste confidential sales data into a tool your organization hasn't approved. The common MMM failures are all about data: no spend variation, channels that always move together, and presenting single numbers as facts.

### Mistakes + try this now

Common MMM mistakes. Building a model on data with almost no spend variation. Ignoring that two channels always moved together. Presenting single numbers without uncertainty ranges. Encoding Ramadan by month instead of actual dates. And treating the model as a one-time project. Try this now: open a spreadsheet and list your last two years of weekly spend by channel. Highlight any channel whose spend barely changed, and any two channels that always rose and fell together. Those are the places your model will struggle, and where an experiment would help most.

### Watch me do it: MMM data prep (illustrative)

Watch me do it. Let's prepare data for an illustrative Meridian model for a Gulf juice brand. Step one, the outcome: weekly unit sales by country, UAE, Saudi Arabia, Kuwait, for three years, from the distributor reports. Step two, media: weekly spend and impressions per channel per country, TV, YouTube, Meta, TikTok, Snapchat and outdoor. I find outdoor has spend but no impressions, so I use spend only and note it. Step three, controls: average shelf price index, promotion weeks, distribution coverage, temperature because juice sells more in summer, and Ramadan and Eid encoded by their actual dates each year. Step four, a quick sanity check: I plot each channel's spend over time. Snapchat was flat every week for two years, so the model won't learn much about it; I flag it for a test. TV and outdoor always ran together in summer; collinear, so I plan a geo split next summer. Step five, priors: last year's Meta lift study suggested a positive return, so I use a prior centered there. Only now do I run the model. Most of MMM is this preparation.

### Recap and next step

Recap. MMM explains outcomes with aggregated data and survives tracking loss. Meridian and Robyn are free and strong, but need good data and judgment. Encode moving holidays properly, respect uncertainty, and calibrate with experiments. Refresh quarterly. Your next step: list the data you'd need for your own model, and mark what you have for at least two years and where you've never varied spend.

## Key takeaways

- MMM explains outcomes with aggregated data by channel and controls — robust to tracking loss, but not a daily tool.
- Meridian (Google, Bayesian, Python) and Robyn (Meta, R) are the leading open-source options.
- You need 2–3 years of weekly data, spend variation and good controls (including moving holidays like Ramadan).
- Adstock, saturation, priors and uncertainty intervals are the core concepts.
- Calibrate with experiments and refresh quarterly.

## Try it

List the data you would need for an MMM of your business: outcome, media, controls and geos. Mark which you have for 2+ years and where you lack spend variation.

- [Previous: Incrementality testing: geo experiments, conversion lift and holdouts](https://optimizeall.com/learn/ai-performance-marketing/incrementality-testing)
- [Next: Guardrails: brand safety, exclusions and policy compliance](https://optimizeall.com/learn/ai-performance-marketing/guardrails-brand-safety-exclusions)
- [All lessons of AI-Powered Performance Marketing](https://optimizeall.com/learn/ai-performance-marketing)
