← Homepage
Applied Data Science Lab · Causal Inference

Active-comparator, new-user cohort study analyzed with difference-in-differences using medical claims and enrollment data: Does Ozempic lower the cost of obesity care?

October 15, 2026

Author: Daniel Jordan Viray

Does Ozempic lower the cost of obesity care? A study design using claims and enrollment data, explained end to end

The question

For members with obesity, does starting Ozempic reduce their total cost of obesity-related care more than starting a different weight-loss drug?

WhoMembers with an obesity diagnosis code on their claims, enrolled for the full study window
ComparedOzempic starters vs. starters of another weight-loss drug
MeasuredObesity-related cost of care, 6 months before vs. 6 months after starting
Part 1 · What we actually have

Our data: claims plus enrollment

This study uses two linked data sources, not claims alone. Every time a member gets care, a claim is submitted so the provider gets paid — claims say what care happened and what it cost. Enrollment records are separate and simpler: they say who was covered, and for exactly which dates. We need both. Claims tell us the care; enrollment tells us whether we can trust a quiet month — and whether a member was observable for the whole study window at all:

  • Who has obesity: an obesity diagnosis code [ICD-10 diagnosis code] appears on their claims. (This finds members whose obesity was coded during care — it can’t find members who never had it written on a claim.)
  • Who started which drug, and when: the first pharmacy claim for Ozempic or for another weight-loss drug. That date is each member’s starting line [index date].
  • What care cost: the paid amounts on all their obesity-related claims, month by month.
  • Enrollment must cover the whole window: we look up enrollment for every member and require them to be enrolled for the entire relevant time — all 6 months before and all 6 months after their first fill [continuous enrollment]. Only then does a quiet month mean $0, not “missing”: the member was covered, so a month with no obesity claims is a month that genuinely cost nothing.
Part 2 · The plan

What we’ll do instead: rebuild the ideal trial from claims and enrollment

In real life, nobody was assigned a drug at random — so instead of comparing Ozempic users to everyone else (which would mix up the drug with the kind of person who gets it), we compare them to the fairest group claims and enrollment can give us: people who also started a weight-loss drug, just a different one. Both groups were in the same situation at the same kind of moment. Then we compare how each group’s costs changed.

What this design is called: a target trial emulation [target trial emulation] — we write down the head-to-head trial we wish we could run, then rebuild each piece of it from claims and enrollment records. The comparison group is an active comparator made of new users [active-comparator, new-user design], and the arithmetic that produces the answer is difference-in-differences [difference-in-differences · DiD]. Those are the names to use when searching the literature or talking with other researchers.

  1. 1
    Find the members — and verify enrollment

    Pull members who have an obesity diagnosis code on their claims and who started a weight-loss drug. Then look up each member’s enrollment and keep only those enrolled for the entire window — 6 months before through 6 months after their first fill [continuous enrollment]. Without that check we could not tell a true $0 month from a month when the member simply was not covered.

  2. 2
    Split into two groups by what they started

    Group A: first fill was Ozempic. Group B: first fill was another weight-loss drug. Everyone in the study started something — nobody is compared against “doing nothing” [active comparator].

  3. 3
    Line everyone up at their own starting line

    Members start in different calendar months, so we line them up by time relative to their first fill — month 0 — not by calendar date [time zero · relative-time alignment].

  4. 4
    Add up obesity-related costs, 6 months before and 6 months after

    For each member, total the paid amounts on their obesity-related claims in each month. Because enrollment has already been confirmed for the whole window, a month with no claims counts as $0 — genuinely no cost, not missing data.

  5. 5
    Compare the changes, not the end points

    Each group is first compared to its own past. Then we compare the two changes. Whatever pushed both groups’ costs around equally — price inflation, the drugs helping in general — cancels out, leaving the extra effect of Ozempic [difference-in-differences].

Part 3 · A toy example

Six members, worked end to end

Here is the whole study in miniature, with made-up numbers small enough to check on paper. Three members started Ozempic, three started another weight-loss drug; all six have an obesity diagnosis code, and in this toy example all six were enrolled for the full 12 months, so every month is observed for every member. The numbers are built in two steps — and each step is exactly what you would do with a real claims and enrollment extract:

Step 1 — get every member’s cost in every month; add each month up within a group to get the group’s total; then divide by the number of members to get the average cost per member. That last column is what the chart plots. Two highlighted rows summarize each period: the Before average, right after month −1, and the After average, right after month +6.
Step 2 — average the members within each group. That produces four group numbers — a before and an after for each group — and comparing the two groups’ changes gives the study’s answer, worked in full right below the table.

Step 1 · Every member, every month

From the claims — after checking enrollment — take each member and add up the paid amounts on all their obesity-related claims within each month, with months lined up relative to their first fill — one cost figure per member per month [member-month panel]. A month when an enrolled member filed no obesity claims counts as $0: it adds zero to the total, and the member still counts in the divisor. All figures are dollars of obesity-related cost for that month.

Ozempic group — monthly cost by member

MonthMariaJamesPriyaGroup total
(all 3 members)
Average
per member

Other-drug group — monthly cost by member

MonthTomAliciaDavidGroup total
(all 3 members)
Average
per member

Read each table top to bottom: one row per month. The group total column is every member’s cost for that month added together. The shaded average per member column [per member per month · PMPM] is that total divided by the number of members — and it is exactly what the chart below plots, month by month, one point per row. Check the first row by hand: in month −6 the Ozempic members cost $940 + $840 + $740 = $2,520 in total, and $2,520 ÷ 3 members = $840 per member — the first point on the teal line.

Step 2 · Average each group — then compare the changes

Average the three members in each group, and the twelve monthly figures collapse into four numbers: a before average and an after average for each group. These are the same figures as the highlighted Before average and After average rows in the Step 1 tables. The third row is the study’s answer — the difference between the two groups’ changes [difference-in-differences]:

GroupBefore
(avg per month)
After
(avg per month)
Change

The arithmetic, step by step

No model, no black box — the headline number in that last row comes from comparing each group to its own past, then comparing those two changes. The only inputs are the four group averages in the Step 2 table: Ozempic $900 before and $630 after; other drug $700 before and $550 after. You land on the same four numbers from the Step 1 tables, too — average the six monthly “average per member” points inside the before window and you get the same $900. Walk through it:

Before
After
Change
Ozempic
per month$900
per month$630
change−$270
Other drug
per month$700
per month$550
change−$150
Difference
—
—
extra saving?
Ozempic group:  $630 − $900 = −$270 a month — their costs fell $270.
Other-drug group:  $550 − $700 = −$150 a month — their costs fell $150.
Difference of the changes:  −$270 − (−$150) = −$120 a month — in this example, starting Ozempic is associated with $120 more saved per member, per month than starting the other drug.

The dashed “expected” line on the chart below is this same subtraction drawn as a picture [counterfactual]: it traces where the Ozempic group’s costs would have landed if they had fallen only as much as the other drug’s did. Two pairs of numbers describe it, and they look inconsistent until you see what each one measures:

Both views tell the same story: the gap between actual and expected is $120 a month either way. And because that gap is the same in every after month, each labeled point on the dashed line sits exactly $120 above the Ozempic group’s actual cost that month. That gap is the number the whole study exists to estimate.

The chart is Step 1 drawn as lines: it plots the shaded “average per member” column for both groups across all twelve months, so you can see the month-by-month trends that the four summary numbers compress.

Monthly obesity-related cost — group averages

Every point on these lines is one month’s average per member figure — the shaded last column of the Step 1 tables above. The teal line is the Ozempic group’s column; the ochre line is the other-drug group’s column. The dashed line is the Ozempic group’s expected path [counterfactual] — every one of its after-period points is labeled, and each sits exactly $120 above the Ozempic group’s actual cost that month: the extra fall the subtraction attributes to Ozempic.

Ozempic group (average) Other-drug group (average) Expected Ozempic path if it had only matched the other drug
Show

Read the chart the way the study does. The two groups don’t start at the same place — Ozempic starters were already costlier ($900 vs. $700 a month), probably because costlier, more complex members are the ones who get the newer drug. So comparing only the “after” numbers ($630 vs. $550) would be rigged. Instead, look at the drop: both groups fall (the other drug helps too), but the Ozempic group falls further. That extra fall is the answer to our question.

Doing this with real claims and enrollment data

Part 4 · Honest limits

What would make us trust — or doubt — the answer

1 · The before picture has to look fair [parallel trends]

The whole method rests on one bet: if the two groups’ costs were already moving together in the six “before” months (as they do in the chart above), it’s reasonable to believe they would have kept moving together after month 0 if everything else were equal. If they were already drifting apart before anyone took anything, we stop — the comparison isn’t fair and no arithmetic fixes it. Here is how that fairness gets checked, not just eyeballed:

2 · The groups start different, and we know it [confounding by indication]

Ozempic starters cost more at baseline — $900 vs. $700 a month — probably because costlier, more complex members are the ones who get the newer drug. Comparing changes removes any gap that stays constant, but if the groups differ in ways that change over time (for example, more members with diabetes in one group), that can still tilt the answer. So before anyone looks at the after-period, we rebuild the comparison group to resemble the Ozempic group:

The bottom line

We can’t run the ideal trial — but by comparing members who started Ozempic with members who started a different weight-loss drug, and comparing how each group’s costs changed from its own starting point, we get the closest honest answer claims and enrollment data can give: whether Ozempic lowers the cost of obesity care more than the alternative.

All member names and dollar figures on this page are a made-up teaching example, not real member data.