Skip to main content

causalgeo

Concurrent geo holdouts for bundle lift and calibrated channel responses

tests DOI Python License

A geo holdout estimates the lift of a bundle. It does not estimate how many sales each channel inside that bundle was worth. causalgeo reports the bundle lift, uses impression paths for a model-assisted channel split when the cells can separate the channels, and reports no number for a channel when the design cannot tell the channels apart.

Key features

Holdout

  • Concurrent cells. Several bundles can go dark in the same weeks. Each cell has its own control markets.
  • An assignment you already have. design_from_assignment takes a cell map. design_concurrent_test assigns markets inside groups you supply. The package does not search for markets or power.
  • The published number is the holdout. A channel left on can still deliver differently in the dark markets. That shift is recorded. It changes the published cell total only if you ask for the refit.

Channel split

  • Model-assisted, and labeled as such. Channel responses come from impression history, calibrated toward the measured bundle lifts. They are not channel-level holdout estimates. A channel slope is sales per impression and is held at zero when the line would slope down. The bundle lift stays free.
  • A channel gets no number when the flight never turns it off, when two impression paths are perfectly correlated, or when the design cannot separate it.
  • The gap stays visible. The bundle table shows the measured lift next to the lift implied by the channel responses.

One bundle

One bundled test is one equation. Eight channels in that bundle are not eight experiments.

  • With an external mix-model prior. bayesian_channel_allocation updates that prior with the measured bundle. It reports how many channel directions the experiment actually tested. One bundle tests one direction.
  • With no prior. anchored_channel_allocation divides the measured total by a sales-per-impression weight you supply. The pieces add back to the holdout. The package does not calculate the weight.

Single-cell lift

analyze() is the one-cell path: time-based regression by default, or synthetic control, synthetic difference-in-differences, or clustered two-way fixed effects. It returns lift, percent lift, and incremental cost per dollar when spend is present. It does not split channels.

Quick start

Installation

The release to install is v0.2.4. It is not on PyPI yet.

pip install "causalgeo @ git+https://github.com/adityapt/causalgeo.git@v0.2.4"

To work on the repository:

git clone https://github.com/adityapt/causalgeo.git
cd causalgeo
pip install -e ".[dev,paper]"

v0.2.0 remains the October archive. It does not include the one-bundle allocation.

Run the example

This builds a small panel. No download. Search is an exact copy of Facebook, so the fit withholds both slopes and reports Display.

python examples/concurrent_holdout.py

Basic usage

from causalgeo import design_concurrent_test, disentangle

design = design_concurrent_test(
    markets,  # columns: geo, stratum
    channels=["Facebook", "TikTok", "Search"],
    bundles=[
        ["Facebook", "TikTok"],
        ["Facebook", "Search"],
        ["TikTok", "Search"],
    ],
    control_share=0.5,
)
result = disentangle(
    design,
    outcomes,     # columns: geo, date, sales
    impressions,  # columns: geo, date, channel, impressions
    outcome="sales",
    treatment_start="2026-08-03",
)

result.channels   # one row per channel; no number when the design cannot separate it
result.bundles    # measured bundle lift next to the lift implied by the channel responses
result.exposure   # still-on impression shift, and whether it was applied

result.channels includes a reading column. A reported slope says it is model-assisted. A withheld slope says why.

One bundle

No mix-model prior

You supply the sales-per-impression weights. Equal weights split the bundle by the impressions the holdout removed.

from causalgeo import anchored_channel_allocation, prevented_effective_dose

dose = prevented_effective_dose(
    impressions,
    design,
    treatment_start="2026-08-03",
)
allocation = anchored_channel_allocation(
    result.cells[["cell", "coef", "std_err"]],
    dose,
    potency={"Search": 1.0, "Social": 1.0, "Video": 1.0},
)

allocation sums to the measured cell effect. ci_lower and ci_upper scale the experimental interval by the chosen share. assumption_lower and assumption_upper move only the potency bounds you pass in.

python examples/anchored_allocation.py

That script splits a bundle of 1,000 into 400, 400, and 200.

With a mix-model prior

The prior is an input. The holdout does not discover it.

from causalgeo import bayesian_channel_allocation, bundle_impression_contrasts

withheld = bundle_impression_contrasts(
    impressions,
    design,
    treatment_start="2026-08-03",
)
allocation = bayesian_channel_allocation(
    prior_mean=mmm_slopes,
    prior_covariance=mmm_covariance,
    bundle_effects=result.cells[["cell", "coef", "std_err"]],
    withheld=withheld,
)

tested_rank is how many independent directions the cells measured. remaining_dimensions is how many stay prior-driven. One eight-channel bundle returns 1 and 7.

python examples/bayesian_bundle.py

Running the other examples

Clone the repository first. The examples/ folder is not part of an installed wheel.

python examples/public_allocation_benchmark.py
python examples/meridian_conversions.py
python examples/prop99_measure.py
python examples/prop99_grid_identification.py

public_allocation_benchmark.py uses Google's public Meridian file geo_all_channels.csv. That copy is Apache 2.0, not MIT. See paper/data/README.md. The file supplies the impression paths. Sales are constructed from known slopes, because the file has no channel-level holdout result. meridian_conversions.py runs the same split on Meridian's conversions column. That run has no known channel responses. It only shows the software on that file.

prop99_measure.py reproduces the published Proposition 99 result, about −15.6 packs per capita. prop99_grid_identification.py shows a design that can separate two policies, and the same design after both policies are collapsed into one indicator.

What a single cell returns

from causalgeo import AssignmentMap, GeoExperiment, Intervention

assignment = AssignmentMap.from_frame(
    assign_df,  # columns: location, role
    universe=kpi["location"].unique(),
)
exp = GeoExperiment(
    kpi,  # location, date, conversions, and spend when you want cost per dollar
    assignment,
    treatment_start="2026-10-01",
    treatment_end="2026-10-31",
    spend="spend",
)
report = exp.analyze(Intervention.GO_DARK)
report.lift, report.percent_lift, report.icpd

Go-dark turns existing media off. Holdback keeps a new activity at zero in control. Heavy-up adds delivery in treatment and leaves control on business as usual. A comparison of two spend arms with no business-as-usual markets raises MissingControlError. Cost per dollar without a spend series raises MissingSpendError.

Use GeoLift or Meridian GeoX when you want a power analysis and a search over which markets to include. causalgeo randomizes the markets you supply into a holdout and business-as-usual groups. Power analysis is not in this release. It is planned for a later one.

GeoLift Meridian GeoX causalgeo
Starting point Pick test markets from a power analysis Search designs and rank them by power Randomize supplied markets into a holdout and business as usual
Counterfactual Synthetic control Time-based regression Time-based regression by default; synthetic control or clustered two-way fixed effects
Channel split No No Model-assisted, no number when the cells cannot separate the channels
Language R Python Python

Benchmarks

Public Meridian geo panel, five channels dark together, sales built from known slopes. Forty markets, 156 weeks, flight from 2023-10-02. Script: examples/public_allocation_benchmark.py.

Check Result
Bundle lift −1,815 (standard error 163) against a planted −1,816
Informed split Channel shares match the planted shares. The check uses the same sales-per-impression weights that built the sales.
Equal-weight split Channel2 receives 7.8% against a planted 2.4%. Channel1 receives 12.7% against a planted 19.2%.

On the manuscript's three-cell series, the straight-line responses are recovered within 0.21%. That series is the response the package fits. It is a check of the software, not evidence that a campaign worked. Rebuild it with:

cd paper
PYTHONPATH=../src python3.11 reproduce.py

python3.11 reproduce.py --fast checks that the scripts finish. It does not check the published numbers. The script sets a Matplotlib cache directory when MPLCONFIGDIR is unset.

Project structure

causalgeo/
├── pyproject.toml
├── README.md
├── LICENSE.txt
├── CHANGELOG.md
├── CITATION.cff
├── CONTRIBUTING.md
├── Makefile
├── src/causalgeo/          # the package
│   ├── design.py           # cell assignment and what the flight can separate
│   ├── calibrated.py       # bundle lift and the model-assisted channel split
│   ├── allocation.py       # divide one measured bundle by a weight you supply
│   ├── bayesian.py         # update an external mix-model prior with the bundle
│   └── experiment.py       # single-cell lift
├── examples/               # scripts you can run
├── tests/                  # 81 tests
└── paper/                  # SoftwareX manuscript and reproduce.py

Development

Python 3.10 or newer. Runtime dependencies are pandas, numpy, scipy 1.11 or newer, and statsmodels. The manuscript figures also use matplotlib.

pip install -e ".[dev,paper]"
python -m pytest
make check

See CONTRIBUTING.md and the code of conduct.

License

MIT. See LICENSE.txt.

Citation

The SoftwareX manuscript is not yet published. Cite v0.2.4: 10.5281/zenodo.24041239.

The concept DOI points at the latest archive: 10.5281/zenodo.23608831. The v0.2.0 archive remains 10.5281/zenodo.23608832.

GitHub's Cite this repository button reads CITATION.cff.

Support

Questions: puttaparthy.aditya@gmail.com

Metadata

Release files for causalgeo 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for causalgeo 0.2.4
File Size Uploaded Provenance Actions
causalgeo-0.2.4.tar.gz 82.7 kB With provenance Details for causalgeo-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for causalgeo 0.2.4
File Interpreter ABI Platform Actions
causalgeo-0.2.4-py3-none-any.whl Python 3 none any Details for causalgeo-0.2.4-py3-none-any.whl

Total release size: 149.2 kB

Release files / causalgeo-0.2.4.tar.gz

Download URL causalgeo-0.2.4.tar.gz
Size 82.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e0d07ce1d4dea64272fa18eddaca5e82172b8c11c797aab26a8ef861d19a25dd
BLAKE2b-256 checksum
How to use checksums
6fea99613020225a072da779fcab9918fa063fa873a92f0c6a83a3b07fe71fdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / causalgeo-0.2.4-py3-none-any.whl

Download URL causalgeo-0.2.4-py3-none-any.whl
Size 66.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a911a8cc161c894e12a9ec394f87c305a70a54f69a5de01d77f2067962feb793
BLAKE2b-256 checksum
How to use checksums
139f9fdbe18102c76c63e27efe6000157ca0b7e64ac601f8651cdebbe8c73b1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for causalgeo 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for causalgeo-0.2.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page