Estimating Continuous Treatment Effects: Doubly Robust Dose-Response Curves

A simulation study of where DoubleML's partially linear model falls short for continuous treatments, and a doubly robust alternative that estimates the whole curve.

Ryan O'Sullivan · Code on GitHub

Not all treatments are binary: marketing spend, price, discount depth, app notifications, customer service response times. Rather than asking "did this treatment work?", we often need to know "what's the right amount?". When the treatment is continuous and chosen rather than randomised, a common choice is double machine learning (Chernozhukov et al. 2018), usually the partially linear model in DoubleML (Bach et al. 2022). For a binary treatment, DoubleML's interactive model is doubly robust; for a continuous treatment, the partially linear model is the usual choice, and it has three limitations that matter in practice:

This article runs one simulation per limitation and shows an estimator that addresses all three: the doubly robust dose-response estimator of Kennedy et al. (2017), with a second stage that partially pools curves across a hierarchy. It then looks at three practical questions: which machine learning models to use, how existing packages compare, and what to do when a confounder is unmeasured.

1. One slope versus a whole curve

Let's start with the partially linear model. DoubleML's DoubleMLPLR fits

Y = θD + g(X) + ε

where D is the treatment, X the confounders and g(X) the effect of the confounders on the outcome. DoubleML estimates θ with two machine learning models: an outcome model, which predicts Y from X, and a treatment model, which predicts D from X. It then regresses what's left of Y on what's left of D (this is called partialling out).

Models like these are called nuisance models: we need them, but don't care about them for their own sake. Cross-fitting (each row's predictions come from models trained on other rows) and an orthogonal score (an estimating equation that is insensitive to small errors in the nuisance models) stop the regularisation in these models from biasing θ, which is what makes its confidence interval valid. The catch is the θD term: it assumes the effect is linear, so every extra unit of treatment has the same effect wherever you start.

If the true effect is a curve, you still get a single slope back: roughly the curve's average slope across the doses in your data.

The alternative is to estimate the whole curve: for every dose a, the average outcome if everyone received dose a. It takes three steps:

Step 1
Cross-fit two nuisance models

An outcome model μ(x, a) = E[Y | X, A]; unlike DoubleML's outcome model, this one includes the dose as an input. And a generalised propensity score (GPS; Hirano and Imbens 2004) π(a | x): the density of the dose given X.

Step 2
Build a pseudo-outcome

Combine them into one number per row, ξ, whose average at each dose is the causal curve.

Step 3
Smooth, with pooling

Regress ξ on the dose with penalised splines (Eilers and Marx 1996), sharing strength across a hierarchy of groups.

Step 2 is where the robustness comes from. It starts with a regression estimate, the outcome model's prediction at dose a averaged over everyone, which on its own is an S-learner. It then adds a correction: the residuals of units that actually got a dose near a, weighted by how unusual that dose was for them so that they represent everyone. If the outcome model is right, the correction is just noise; if it's wrong, the correction removes the error, provided the model of who gets which dose is right. One of the two has to be right, not both: that's double robustness.1

Step 3 turns these noisy per-row numbers into a smooth curve and, when there are groups, lets small groups borrow strength from larger ones.

1 The pseudo-outcome is ξ = (Y − μ(X, A)) · ϖ(A)/π(A | X) + m(A), where μ is the outcome model, π the density of the dose given X, ϖ the overall density of the dose and m(a) the outcome model averaged over X at dose a (Kennedy et al. 2017). For a binary treatment this is the AIPW estimator behind DoubleML's DoubleMLIRM.

2. Nonlinear effects

Two nonlinear shapes are common:

In practice you rarely know the shape in advance, and the decision you need to make (how much, and where to stop) depends on it. So the method should find the shape rather than assume it.

The simulation:

Estimated dose-response curves: DR vs DoubleML
True curveDR curve (95% band)DoubleML PLR
Inverted-U effect
-2-10-101Treatment a
Saturating effect
-2-101-101Treatment a

Each panel is one simulated dataset. Dashed black: the true dose-response curve. Blue: the DR curve, with a 95% band. Orange: DoubleML's estimate, a straight line with slope θ. Curves cover the middle 90% of observed doses and are centred, since only the shape is being compared.

The DR curve follows both shapes. DoubleML's line can only tilt. On the inverted U its slope is close to zero: read on its own, it says the dose doesn't matter, when moving away from the middle in either direction costs a lot. On the saturating curve it gives every unit the same return, understating it at low doses and overstating it at high ones.

3. Robustness to a wrong nuisance model

Both nuisance models are approximations, and with a continuous dose the model of who gets which dose is especially easy to get wrong: it has to describe the whole spread of doses each unit might get, not just the average one. Doses are often set by unwritten business rules (pricing tiers, budgets split by last year's revenue, a cap on notifications), and some segments see a narrow range of doses while others see a wide one. The outcome model can be wrong too. So the test is what happens when one of them is wrong.

DoubleML's partially linear model has two scores (estimating equations). The default, partialling out, only protects against a wrong outcome model: if the treatment model is wrong, θ is biased however good the outcome model is (Valentin et al. 2025). The alternative IV-type score is doubly robust, but only for the single slope θ. What we want is a doubly robust curve, which is what the pseudo-outcome from section 1 provides.

The simulation:

Each dataset gets a correct and a wrong version of the outcome model and of the dose model. The S-learner uses the outcome model alone, so it shows what the wrong outcome model costs you.

Estimation error with right and wrong nuisance models
Truth (zero error)S-learnerDoubly robust (90% of runs)
Outcome model wrong
-0.500.5-1012Treatment a
Dose model wrong
-0.500.5-1012Treatment a
Both wrong
-0.500.5-1012Treatment a

Each panel shows each estimator's error: its average estimated curve over 30 simulated datasets, minus the true curve. The dashed line at zero is the truth, so the closer to it the better. The blue band shows where 90% of the individual DR curves fall. Curves are centred.

With the outcome model wrong, the S-learner misses the curve, while DR stays much closer, because the weighted residuals correct most of the error. With the dose model wrong, DR stays close. With both wrong, DR misses too: it needs at least one model right. DR's remaining error sits at the ends of the dose range, where the wrong outcome model is most wrong and the fewest units are available to correct it.

4. Choosing the nuisance models

Real data rarely has a handful of confounders. A customer table has dozens of features: tenure, spend history, products held, past contacts. Most of them nudge both the dose a customer gets and their outcome a little. You don't know which matter or how, so both nuisance models end up as flexible, regularised machine learning models. The choice of learner changed the answer a lot.

The simulation:

Estimated curves by choice of learner, 50 confounders
True curveS-learnerDR, density weightsDR, balancing weights
Boosting alone
-4-20-1012Treatment a
Stacked: splines + boosting
-4-20-1012Treatment a

Average estimated curve over 30 simulated datasets. Left: every nuisance model is boosted trees. Right: every nuisance model is the stack. Dashed black: the true curve. Curves are centred; the density-weight curve on the left runs off the chart.

With boosting alone, the S-learner's curve is too flat, because boosted trees shrink the dose's effect. Density weights are far off: the boosted dose model gives some doses a near-zero probability, so their weights explode. Balancing weights, which need no density, do best. With the stack, all three recover the curve, because the spline regression captures the smooth relationships that trees can only approximate with steps.

In practice: with the stack, density weights work well; if you use boosting alone, use balancing weights instead. That doesn't make the stack better everywhere: section 6 tests it on harder data, where trees have the edge.

5. Many curves: borrow strength across the hierarchy

The decision is rarely one curve for the whole business. Pricing teams set discounts by category, marketing teams set budgets by country and channel, CRM teams set cadence by segment. The groups are nested (stores in regions, products in categories, campaigns in channels), and their sizes follow a long tail: a few big ones with plenty of data and many small ones with very little.

There are three ways to handle the groups:

θstore(a) = B(a)′ ( βglobal + bregion + bstore )

B(a) is a set of spline basis functions. A small store's deviation is shrunk toward its region, and a region's toward the global curve. A big store has enough data to overrule the shrinkage. How hard to shrink at each level is chosen from the data. Because the DR pseudo-outcome is just a number per row, the pooling sits on top of it unchanged: the DR step handles confounding, and the pooling handles the hierarchy.

The simulation:

Error in each store's dose effect, by number of customers in the store
Partial poolingNo poolingComplete poolingDoubleML per store
00.511.5Partial pooling: 0.410.41No pooling: 0.760.76Complete pooling: 0.780.78DoubleML per store: 1.781.78<25 customers29 storesPartial pooling: 0.350.35No pooling: 0.470.47Complete pooling: 0.820.82DoubleML per store: 1.171.1725–60 customers77 storesPartial pooling: 0.330.33No pooling: 0.380.38Complete pooling: 0.780.78DoubleML per store: 0.840.8460–150 customers60 storesPartial pooling: 0.250.25No pooling: 0.240.24Complete pooling: 0.940.94DoubleML per store: 0.700.70150+ customers34 storesRMSE of the store's dose effect

One simulated dataset. Root mean squared error of each store's estimated change in outcome between the 25th and 75th percentiles of the dose, grouped by the number of customers in the store.

Without pooling, the error grows as stores get smaller. DoubleML per store is worst in all but the biggest stores. Even there, with 150 or more customers, its error stays around 0.7, because a straight line can't follow the curve; the extra error in small stores comes from refitting the nuisance models on a few dozen rows. Complete pooling's error stays high even in big stores, because every store gets the same curve. Partial pooling has the lowest error in small stores, because it pulls them toward their region; in big stores it matches no pooling, because the data overrules the shrinkage.

6. How does this compare with existing packages?

Two packages already estimate a single doubly robust curve with the pseudo-outcome from section 1:

Neither cross-fits the nuisance models, and neither handles groups. Below, we compare them with drcurves, the open-source Python package written for this article, which does both.

We ran all three on three settings, ten simulated datasets each:

Each package used its defaults, with two exceptions for npcausal: we gave it a range of bandwidths to choose from, and with 50 confounders we dropped the pairwise-interaction learner from its library, which didn't fit in memory.

Error in the estimated curve, by package
npcausal (R)causal-curve (Python)drcurves (Python)
00.20.40.6npcausal (R): 0.080.08causal-curve (Python): 0.540.54drcurves (Python): 0.060.065 confoundersnpcausal (R): 0.180.18causal-curve (Python): 0.300.30drcurves (Python): 0.040.0450 confoundersnpcausal (R): 0.300.30causal-curve (Python): 0.430.43drcurves (Python): 0.240.24Harder dataRMSE of the curve

Root mean squared error between the estimated and the true curve, averaged over the simulated datasets in each setting. Curves are centred. On the harder data, npcausal failed on 1 of the 10 datasets, so all three are compared on the other 9.

7. When confounders are unmeasured: difference-in-differences

Everything so far assumes you've measured the confounders. Often you haven't. A customer's underlying complexity, a team's culture, a store manager's skill: stable traits that push both the dose and the outcome, and never appear in the data. No estimator fixes that, but with pre-period data a different assumption can.

If you observe the outcome before the dose changed, and the hidden trait is stable over time, difference-in-differences removes it: fit the same method on the change in outcome rather than its level. To compare doses, rather than just treated against untreated, this needs a stronger form of parallel trends: units on different doses would have followed the same path had their doses been the same (Callaway, Goodman-Bacon and Sant'Anna 2024).

The simulation:

Error in the estimated curve with a hidden, stable trait
00.250.50.751Error: 1.061.06Adjust for XError: 0.290.29Adjust for X andthe pre-period outcomeError: 0.040.04DiD: fit on the changeRMSE of the curve

Root mean squared error between the estimated and the true curve, averaged over 10 simulated datasets. Curves are centred.

Adjusting for X alone leaves the trait confounding the curve. Adding the pre-period outcome helps, because it partly stands in for the trait, but the curve is still biased. Fitting on the change recovers it, because the trait cancels.

The ranking flips if the dose responds to past outcomes rather than to a stable trait: then adjusting for the pre-period outcome is right and DiD is biased. You can't tell which from the data alone. A placebo helps: fit the curve on the change between two pre-periods, where the dose can't have had an effect yet. A clearly non-flat curve warns that parallel trends doesn't hold. Judge it by its size relative to the effect you care about, not by whether its band includes zero: even when parallel trends held in our simulation, about 30% of the placebo curve fell outside its 95% band.

Frequently asked questions

Can I trust the intervals?

Treat them as optimistic. With the stacked default, the 95% bands contained the true curve 75-93% of the time across our simulations. Capping the most extreme weights, which trades a small bias for a lot of stability, is one likely reason. When the nuisance models are off the bands are too narrow, because a band doesn't account for bias. Check on your own data: keep your real confounders and doses, simulate an outcome with a known curve, rerun the whole pipeline 20 to 30 times, and count how often the band contains it. This is a plasmode simulation (Franklin et al. 2014), and if the bands fall short it tells you how much to widen them.

When shouldn't I use this?
  • Unmeasured confounding. Double robustness protects against a wrong model, not a missing variable.
  • Poor overlap. If some units only ever get low doses, the data can't say what high doses would do for them. Report the curve only over doses you actually see.
  • Dose set at the group level. If every customer in a store gets the store's discount, the store is the unit of analysis. Aggregate first.
  • A spike at zero. "Any versus none" and "how much" are different questions; analyse them separately.
  • Crossed groups. The pooling assumes nesting (stores within regions). Store × channel needs a different model.
Why not bin the treatment and use a discrete estimator?

DoubleML's DoubleMLAPOS estimates average potential outcomes for discrete treatment levels, so binning the dose is an option. It throws away the ordering of the doses, each bin needs its own propensity model and enough data, and the answer depends on where you put the cut points. Within a bin, units with different doses are treated as if they got the same one.

What about a polynomial in the treatment, as in EconML?

EconML's DML estimators accept a treatment featurizer, so you can fit θ₁D + θ₂D². That handles a simple curve, but you choose the shape in advance, it is still a partially linear model with the same score, and it does not pool across groups.

Is there a kernel version of double machine learning for this?

Yes. Colangelo and Lee (2020) estimate the curve one dose at a time with a kernel-localised doubly robust score, and Klosin (2021) does it without estimating the density. Both are good options for a single population curve with careful inference. The pseudo-outcome approach here was chosen because the second stage can be any regression, which is what makes the hierarchical pooling simple.

Could I do the pooling in a Bayesian model instead?

Yes. The ridge penalties are Gaussian priors on the deviations, tuned by cross-validation rather than given hyperpriors. Fitting the same spline structure in PyMC or brms on the pseudo-outcomes gives full posteriors for each store's curve, at more computational cost.

Conclusion

With a continuous treatment, the partially linear model answers a narrower question than you usually need. The question is about a curve:

The simulations use one data-generating process per question, known confounders and moderate sample sizes. They do not show how often each problem occurs in your data. The questions to ask are the same, though: is the curve likely to bend, which nuisance model are you least sure of, how many groups need their own answer, and what are you assuming about the confounders you can't see?

The package, drcurves, has the estimator, the simulations and the script that builds every chart and number on this page.

References