Representative interview topic

Data Science Interview: Why can adjusting for a post-treatment variable bias an A/B test?

DataHard
Offer.cc Editorial TeamPublished Updated

Question

A treatment changes whether users click a panel, and you want to compare purchases only among users who clicked. What can go wrong, and what would you report?

Prompt and setting

The click is observed after assignment and is affected by treatment. Restricting analysis to clickers may look like a useful subgroup comparison, but it can destroy the randomization that identified the overall treatment effect.

What the interviewer tests

  • Distinguishing pre-treatment moderators from post-treatment mediators.
  • Explaining collider and selection bias with a causal graph.
  • Choosing an estimand that matches the product decision.

Clarifying questions before answering

  • Is the click measured before assignment, after assignment, or both?
  • Is the decision about total impact, the effect among compliers, or a mechanism through the panel?
  • Are there pre-treatment variables that predict clicking and purchasing?
  • Was the click filter planned before the experiment and supported by a valid identification strategy?

30-second answer framework

I would not compare purchasers only among observed clickers as the primary result. Clicking is a post-treatment mediator and may also be affected by unmeasured traits that predict purchase. Conditioning on it can open a non-causal path and de-randomize the arms. I would report intent-to-treat for all assigned users, then use a pre-specified mediation or principal-stratification analysis only with explicit assumptions.

Step-by-step deep dive

1. Draw the time order

Assignment precedes click, and click precedes purchase. A baseline trait can influence both click and purchase. Treatment also influences click, so the clicker subset is selected using a variable downstream of treatment.

2. State the causal question

Total effect asks what would happen if the product shipped to the assigned population. A mechanism question asks how much effect travels through the panel. A responder question asks about users whose click behavior would be the same under either arm. These are different estimands.

3. Show why filtering fails

Within the clicker subset, treatment and control users can differ in latent purchase propensity because treatment changed who entered the subset. The original randomization protects the full assigned population, not an arbitrary post-treatment slice.

4. Select a defensible analysis

Use intent-to-treat as the launch estimate. For mediation, pre-specify baseline covariates, define the mediator and outcome windows, and state assumptions about mediator-outcome confounding. For compliance questions, consider principal stratification or instrumental-variable methods when their assumptions are credible.

5. Communicate limitations

Show the overall estimate, click rates by arm, and the secondary analysis separately. Do not call the clicker comparison causal merely because the sample is large or the click event is observable. Explain which conclusions are identified and which rely on assumptions.

High-quality sample answer

“The click occurs after assignment and is changed by treatment, so filtering to clickers conditions on a mediator. That can select different latent purchase propensities in treatment and control and break the randomization protection. I would use intent-to-treat for the launch decision, show click rates and the overall purchase effect, and treat any mechanism or responder analysis as secondary. I would pre-specify a causal graph and assumptions before using mediation or principal-stratification methods.”

Common mistakes

  • Compare only clickers → treatment changes who is included → keep intent-to-treat as primary.
  • Call click a baseline segment → it is measured after assignment → record the time order.
  • Adjust for every observed behavior → post-treatment conditioning can open bias paths → use justified pre-treatment covariates.
  • Treat a large subgroup as causal → precision does not restore identification → state estimand and assumptions.

Follow-up questions and responses

Can I still report the clicker result?

Yes, as a descriptive or explicitly assumption-dependent secondary result. Label it as an association within observed clickers and show how the filter changes arm composition.

Why not simply control for the click in regression?

Regression adjustment does not make a post-treatment variable pre-treatment. It can block part of the treatment effect and create collider bias when unmeasured causes affect both click and purchase.

What if the product decision is specifically for clickers?

Define the target as a principal stratum, such as users who would click under either arm, and use an identification method whose assumptions you can defend. Observed clickers are not automatically that stratum.

Public sources

Related questions