Skip to content

Causal Forests

Causal forests are a random-forest method that estimates how a treatment's effect differs between units with different characteristics. Its target is the conditional average treatment effect, and it relies on treatment being randomized or unconfounded given the covariates.

Three platforms, three answers, one budget to defend. Your GA4 export already holds the answer, and the first finding is free and never leaves your browser. Get your first finding free

By , Founder & CEOUpdated 7 min read

What are Causal Forests?

A causal forest estimates the conditional average treatment effect, written tau(x): the average difference between the outcome with a treatment and the outcome without it, among units whose characteristics equal x. The documentation of grf, an R package for generalized random forests, defines it for a binary, unconfounded treatment as E[Y(1) - Y(0) | X = x]. No unit is observed both treated and untreated, so the forest never measures an individual's effect. It estimates an average for units that look alike on their characteristics.

The method extends Breiman's random forest, which averages many decision trees. A random forest picks splits that separate average outcomes. In grf, a causal forest instead picks splits so that the estimated treatment effect differs between the two sides, and it requires a minimum number of treated and of control units in each node it creates. Honest estimation uses one part of the data to choose the splits and another part to fill the leaves. To estimate the effect for one customer, the forest gathers training customers who fall in the same leaves, weights them by how often they do, and computes the effect from their outcomes and treatment status.

Causal forests assume that potential outcomes are independent of treatment assignment once the covariates are conditioned on, which is called unconfoundedness. A randomized test satisfies it by design. In observational data it is an assumption argued from domain knowledge, and the forest does not test it. Under it, Wager and Athey, in their 2018 paper, show that the estimates are pointwise consistent and asymptotically Gaussian, and they describe how to build confidence intervals.

The grf guide's practical check on heterogeneity is train/test evaluation: fit the model on one set, then group held-out units by predicted effect and see whether measured effects differ across the groups. In both of the guide's worked examples, the test on the forest's own predicted-effect ranking does not detect heterogeneity, so an empty result is possible.

For illustration, suppose a store sends a discount email to a random half of a list and measures spend in the following week. Suppose repeat buyers spend 6 euros more with the email and first-time buyers spend the same as without it. If the two groups are equal in size, the overall effect is (6 + 0) / 2 = 3 euros, and that figure describes neither group. Here a causal forest would try to recover the 6 and the 0 from attributes recorded before the email, such as the number of past orders.

Why Causal Forests matter for ecommerce

A single average effect can hide who responds. If a discount email lifts spend for repeat buyers and does nothing for first-time buyers, one blended figure points to sending the same email to everyone. The grf reference notes that the average treatment effect can be zero even when effects differ across a population, so a flat average does not rule out groups that respond. A causal forest is one way to look for those groups using attributes a store already holds, such as past orders. It answers the question only when the data come from a randomized test or from an argument that treatment was unconfounded. A 2019 Marketing Science paper on Facebook ad experiments reported that observational methods often failed to reproduce the randomized results, even after conditioning on extensive demographic and behavioral variables.

How to use Causal Forests

  1. Choose a treatment and an outcome, and randomize if you can: send a discount email to a random half of a customer list, or hold out a random share. Fix the outcome window before the send, such as orders in the following weeks.
  2. Build one row per customer with the treatment flag, the outcome and attributes known before treatment, such as past orders, first-order channel and country, as the grf guide's examples do with pre-treatment covariates.
  3. Fit the forest with grf in R. If assignment was random, pass the known assignment probability, which grf accepts instead of estimating it. If a customer or household appears in several rows, pass cluster identifiers so variance estimates account for it.
  4. For customers in the training data, use out-of-bag predictions, which grf returns when predict is called without new data. For new customers, predict from their attributes.
  5. Test the heterogeneity on held-out data: fit on one part of the customers, group the held-out part by predicted effect and compare measured average effects across the groups. The rank_average_treatment_effect function in grf automates this.
  6. Read the result. Pass: groups ranked by predicted effect show clearly different measured effects on held-out data, and the pattern holds in a second randomized test before any budget moves. Fail: the groups look alike, or the pattern disappears in the new test. Then report the overall effect and do not target on the forest's ranking.

Formula

tau(x) = E[Y(1) - Y(0) | X = x]

Where:
- tau(x): the conditional average treatment effect for units with characteristics x
- Y(1): the outcome if the unit is treated
- Y(0): the outcome if the unit is not treated
- X = x: the unit's characteristics, measured before treatment

The forest estimates tau(x) for each x from observed outcomes, and no unit is observed both treated and untreated.

Common mistakes

  1. Using who opened an email or saw an ad as the treatment and reading the output as causal. Customers who chose, or were chosen for, exposure differ before any treatment. Unconfoundedness is an assumption the forest does not test. The cost is a targeting rule built on a selection effect.
  2. Treating each customer's predicted effect as a measured fact. A customer is observed treated or untreated, never both, so an individual effect is never observed. The forest reports estimates for customers with similar attributes. The cost is a claim about one person that the data cannot check.
  3. Judging the forest on the same customers it was trained on. The grf guide says reusing the same data removes the exact finite-sample guarantees for its test statistic, and it recommends train/test evaluation as the pragmatic check. The cost is a pattern that does not replicate.
  4. Using many attributes with a small sample. The guide says fitting the effect on all covariates with train/test evaluation may be underpowered when the sample is moderate relative to the number of predictors. The cost is a check that cannot detect real differences.
  5. Averaging the per-customer predictions to report the overall effect. The grf reference says a more accurate estimate comes from its average_treatment_effect function, and the guide describes the method it uses, augmented inverse-propensity weighting, as combining propensity scores and conditional mean estimates. The cost is an overall figure with more error than necessary.

Frequently asked questions

  • What is a causal forest in simple terms?
    A causal forest is a machine learning method that looks for groups of customers whose response to a treatment, such as a discount email, differs, and estimates the average effect for each group. It extends the random forest and is meant for data where treatment was randomized or is argued to be unconfounded.
  • How is a causal forest different from a random forest?
    A random forest picks splits that separate average outcomes in order to predict an outcome. A causal forest picks splits that separate estimated treatment effects, requires both treated and control units in its nodes, and targets an effect rather than a prediction. The grf guide notes that machine learning methods are designed for prediction, while causal applications often aim at inference rather than prediction.
  • Can causal forests tell me which customers to target?
    They can rank customers by estimated effect, but the ranking needs a check on held-out data, such as grf's train/test evaluation, before it is used to target. In both of the grf guide's worked examples the test on the forest's own ranking does not detect heterogeneity, so the check can come back empty.
  • Do causal forests work on observational ecommerce data?
    Only as far as unconfoundedness holds: the factors that drive both exposure and purchases must be in the covariates. The grf guide calls this an assumption to live with depending on domain knowledge, and a 2019 study of Facebook ad experiments found observational methods often failed to match randomized results.

Further reading

Your platforms guess.
We run the math.

Upload a GA4 export and see what each channel caused, next to last-click, in 1–2 minutes. The read is yours to keep.

The free finding runs in your browser. Your file never leaves it. The full read is €99, refundable within 30 days, no questions asked. Prices exclude VAT.