2.1 Observational studies

Regression adjustment and good and bad controls: what to adjust for, and how

In an observational study, people choose their treatment, so the groups differ before the treatment starts. Adjusting for the right variables can remove this difference. This page shows how regression adjustment works, when one regression coefficient misses the average effect, and why a study should not adjust for some variables.

In brief

A shop sells a paid membership, and each customer decides whether to join. The shop wants the effect of joining on spending in the next month. Loyal customers join more often, and they also spend more without the membership.

Move the sliders and watch these numbers. The explanation below the simulation gives the reasons.

Try it

The simulation has two parts, each with its own settings. Part 1 compares four estimates of the effect of the membership. Part 2 asks which variables a regression of sales on advertising should adjust for.

How the simulation makes the data

In part 1, spending without the membership rises from one segment to the next. The curvature slider bends the rise in spending. When the joining slider is at 0, about three in four customers join in every segment. The simulation knows both potential outcomes of every customer. All amounts in part 1 are in dollars.

In part 2, the page draws 500 stores, regresses sales on advertising with and without Z, and repeats this 400 times. With more than 500 stores, it repeats the draw 200 times, so that the page stays fast. The true effect of advertising is 1 in every case.

Part 1. Regression adjustment for the customer segment

The shop has 2,000 customers at first, in four segments of the same size. The joining slider sets how strongly the segment drives joining. The effect of joining rises across the segments by the effect-difference slider and averages 10 dollars.

At 0, joining has nothing to do with the segment.

At 0, spending without the membership rises by the same amount from one segment to the next.

    Dots show the average spending of members and nonmembers in each segment. A missing dot means that the segment has no customers in that group. The dashed lines show the true averages with and without the membership. The two dotted gray lines show the fit of the regression with a straight line in the segment number. This regression assumes the same rise in spending from each segment to the next and the same effect in every segment. Hover over a dot to see its values.
      Each dot is an estimate, and each vertical line is its 95% confidence interval. The intervals use robust standard errors, which allow the variance to differ across groups. The dark dashed line marks the true ATE, and the light dashed line the true ATT. Hover over a dot to see its values.
      A. Simple difference in means
      B. Regression with a straight line in the segment number
      C. Segment differences weighted by segment size
      D. Regression with a separate intercept for each segment
      True ATE (simulation only)
      True ATT (simulation only)
      Average of the true segment effects with the weights of D (simulation only)

      Each estimate shows its 95% confidence interval in parentheses.

      The segments and the weights of estimators C and D
      SegmentNewOccasionalRegularLoyal
      Members
      Spending without membership
      True effect
      Weight in C
      Weight in D

      Spending without the membership and the true effect are the segment values that the simulation uses. Only a simulation knows them.

      Part 2. Good and bad controls

      A chain of stores wants the effect of local advertising (D) on sales (Y). Each choice below adds a third measured variable, Z, in a different place in the causal diagram. Some choices also add a hidden variable that nobody measured (U).

      At 0, Z is unrelated to everything else. In the M-structure, the arrows from the hidden U1 and U2 have the same strength. In the last case, the hidden confounder U keeps a strength of 0.6.

        The diagram shows D for advertising, Y for sales, and Z for the third variable. Dashed circles are variables that nobody measured. Each dot in the chart is the average estimate over the repeated samples, and each vertical line covers the middle 95% of the estimates. The dashed line marks the true effect. Hover over a dot to see its values.
        The two regressions over 400 samples
        Regression of sales onAdvertisingAdvertising and Z
        Average estimate
        Standard deviation
        95% intervals that contain the true effect of 1
        Bias in large samples

        The bias in large samples comes from the linear model with the current strength. Only a simulation knows it.

        The idea

        A shop sells a paid membership, and each customer decides whether to join. The shop wants the effect of joining on spending in the next month. Loyal customers join more often, and they also spend more without the membership. So the simple difference between members and nonmembers mixes the effect with an old gap. It equals the average treatment effect on the treated (ATT) plus selection bias, as the key terms explain.

        Suppose that the customer segment (new, occasional, regular, or loyal) is the only common cause of joining and spending. This is the assumption of no unmeasured confounding, also called unconfoundedness or selection on observables. Suppose also that every segment has both members and nonmembers. This is called overlap, or positivity. Then a comparison inside each segment is unbiased.

        Comparing inside segments is called adjusting for the segment, and a variable that a study adjusts for is called a control. The average of the comparisons, weighted by the segment shares of all customers, is the average treatment effect (ATE). This method is regression adjustment by imputation. It predicts the spending of each customer with and without the membership, here from the segment averages. Then it averages the difference over all customers (Hernán and Robins 2020, ch. 13).

        A common shortcut is one regression of spending on a membership indicator and a separate intercept for each segment. Its single membership coefficient weights each segment by its size times \(p(1 - p)\), where p is the segment's share of members (Angrist 1998). Segments where almost everyone or almost nobody joins get little weight. If the effect differs across segments, this coefficient is a different average than the ATE. Module 1.2 shows the same weights in a block experiment.

        In symbols, let the segments be \(s = 1, \ldots, 4,\) with segment shares \(w_s\). Let \(p_s\) be the member share and \(\tau_s\) the effect in segment \(s\). The imputation estimator targets \(\sum w_s \tau_s = \text{ATE}\). The membership coefficient of the regression with segment intercepts targets

        \[\frac{\sum w_s p_s (1 - p_s) \tau_s}{\sum w_s p_s (1 - p_s)}\]

        Two more problems: a straight line and a lack of overlap

        A regression model can add two more problems. One is a straight line in the segment number, which counts the segments from new to loyal. Such a line misses a curved pattern in spending, and the bias does not shrink with more data.

        The other is a lack of overlap: if a segment has only members, no comparison inside it is possible. A model can still extrapolate a number for that segment. The number then comes from the model, not from the data. Its 95% confidence interval contains the truth less often than 95% of the time (Hernán and Robins 2020, ch. 13).

        Which variables belong in the adjustment? A causal diagram, or directed acyclic graph (DAG), draws each variable as a node and each direct cause as an arrow. A path is a chain of arrows between two variables, in any direction. Adjusting for a variable on a path blocks the path, unless the variable is a collider.

        A back-door path is a path between the treatment and the outcome that starts with an arrow into the treatment. Adjusting for a set of variables gives the causal effect if the set blocks every back-door path and contains no variable that the treatment affects. This rule is the back-door criterion (Cinelli, Forney, and Pearl 2024).

        The rule sorts candidate variables into good and bad controls (Cinelli, Forney, and Pearl 2024):

        In part 2, every variable is a linear function of its causes plus independent noise with variance 1. Advertising D has a true effect of 1 on sales Y. The strength slider sets every arrow into and out of Z, and in the M-structure also the arrows from the hidden variables. In the last case, the hidden confounder keeps a strength of 0.6.

        References

        1. Angrist, J. D. (1998). Estimating the labor market impact of voluntary military service using Social Security data on military applicants. Econometrica, 66(2), 249-288. https://doi.org/10.2307/2998558
        2. Cinelli, C., Forney, A., & Pearl, J. (2024). A crash course in good and bad controls. Sociological Methods & Research, 53(3), 1071-1104. https://doi.org/10.1177/00491241221099552
        3. Hernán, M. A., & Robins, J. M. (2020). Causal inference: What if. Chapman & Hall/CRC. Chapter 13, Standardization and the parametric g-formula (sections 13.3 and 13.5, and Fine Point 13.1). https://miguelhernan.org/whatifbook
        4. Huntington-Klein, N. (2025). The effect: An introduction to research design and causality (2nd ed.). Chapman & Hall. Chapter 8, Causal Paths and Closing Back Doors. Free online edition: https://theeffectbook.net/ch-CausalPaths.html