ANCOVA: Comparing Groups While Adjusting for a Covariate

Comparing group means is easy. Comparing them fairly — after one group started ahead — is where analysis of covariance earns its keep.

Follow along: actg175.csv — 2,139 patients from the ACTG 175 HIV trial (20 columns), including their treatment arm, baseline CD4 count, and CD4 count at week 20. Download the CSV and run it yourself in Stratum.
There is no ANCOVA menu item — and that is the whole point. You build it as a regression.

Four HIV treatments, one question: which arm leaves patients with the highest CD4 count after 20 weeks? You could just compare the four group averages. But patients don't arrive at a trial identical — some start with more CD4 cells than others. If one arm happened to enroll healthier patients, its higher final count could be a head start, not a better drug. Analysis of covariance is how you tell the two apart.

What ANCOVA actually does

Analysis of covariance compares group means the way a plain ANOVA does — but first it holds a continuous covariate constant. It asks the fairer question: if every patient had started at the same baseline CD4 count, which arm would end up ahead? By adjusting each group's mean for the covariate, it strips out differences that were already present before treatment and isolates the treatment's own effect.

Mechanically, it is nothing exotic. ANCOVA is just a regression with two kinds of predictor: a categorical factor (the treatment arm) and a numeric covariate (baseline CD4). The factor answers "do the groups differ?" and the covariate answers "after accounting for where they started?" That is why Stratum has no separate ANCOVA command — you assemble it from the regression builder, one categorical predictor plus one numeric covariate, side by side.

Building the model from menus

Open Analyze ▸ Linear Regression. Set the response to cd4_week20. Add arm as a categorical predictor and cd4_baseline as a numeric covariate. That layout — one factor, one covariate, on the same response — is analysis of covariance.

Stratum's linear regression builder with cd4_week20 as the response, arm as a categorical predictor, and cd4_baseline as a numeric covariate
One categorical factor (arm) and one numeric covariate (cd4_baseline) on the same response. This builder layout is analysis of covariance — no special command required.

Set the reference: everyone measured against the standard of care

A categorical factor with four arms becomes three comparisons, and every comparison needs a baseline to be measured against. Open arm's Reference picker and set it to ZDV only — the standard of care. Now each arm's coefficient reads plainly: cells gained versus ZDV alone, for patients who started at the same baseline count. That single choice is what separates ANCOVA from a vague group comparison; skip it and the numbers lose their anchor.

Stratum's per-categorical Reference picker for the arm factor, set to ZDV only
Setting arm's reference level to ZDV only makes every arm coefficient read "cells gained versus the standard of care, at equal baseline."

Reading the adjusted effects

The report shows the covariate and the three arm effects together. Baseline CD4 carries a slope of +0.715: each additional cell at baseline is worth about 0.715 cells at week 20 — the head start, measured. With that head start held constant, the arm dummies show the drugs' own contributions:

TermCoefficientReading (vs ZDV only, at equal baseline)
cd4_baseline (covariate)+0.715+0.715 week-20 cells per baseline cell
arm = ZDV + ddI+70.2the strongest arm — ~70 cells above the standard of care
arm = ddI only+42.3~42 cells above the standard of care
arm = ZDV + ddC+36.2~36 cells above the standard of care
intercept+83.6ZDV only at baseline = 0

Every one of these coefficients clears the significance line comfortably — all four are significant at p<.001, with the smallest test statistic (for ZDV + ddC) still at t ≈ 5.1. These are real, adjusted differences, not baseline artifacts.

Stratum regression report showing the baseline slope, three arm coefficients with p-values, and the R-squared line
The fitted report: baseline slope, three arm effects with their p-values, and the R-squared line that tells the real story.

Why the covariate is doing the heavy lifting

Here is the payoff. Fit the treatment arm alone — a plain group comparison — and it explains almost nothing: R² ≈ 0.02 (0.027). Add the baseline covariate and R² jumps to about 0.37 (0.370). The covariate soaks up the patient-to-patient variation that a bare group comparison leaves as noise, and against that quieter background the treatment differences become clear and precise. Adjusting for where patients started didn't just make the comparison fairer — it made it far more powerful.

When you have the answer, capture it. Export ▸ PDF writes a clean report you can hand to a colleague; Stratum's reports export to PDF or text, so the coefficients table and the R-squared line travel together.

When to reach for analysis of covariance

ANCOVA is the right tool whenever a group comparison could be contaminated by a pre-existing difference you can measure:

  • A clinical trial where patients start at different severities — adjust for the baseline measurement, as we did here.
  • An A/B test where the groups differ in size, tenure, or prior spend — hold the covariate constant and compare on level ground.
  • Any experiment with a pre-test / post-test design, where the pre-test score is the natural covariate.

The recipe is always the same in Stratum: linear regression, one categorical factor, one numeric covariate, and a reference level chosen so the coefficients read the way you want to talk about them. No R, no SPSS, no code — just the menus.

Download Stratum

Related: How to Run a Linear Regression → · How to Run a One-Way ANOVA →

ancovaregressionhow-to