# Różnica w różnicach (difference-in-differences)

EN: **Difference-in-differences (DiD)** · id `diffindiff` · aliases: difference-in-differences, diff-in-diff, DiD, różnica różnic

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Fundamenty i rozumowanie](https://aiatlasgraph.com/t/foundations.md) › [Modele probabilistyczne](https://aiatlasgraph.com/t/probabilistic.md) › [Wnioskowanie przyczynowe](https://aiatlasgraph.com/t/causalinference.md) › [Eksperymenty naturalne i quasi-eksperymenty](https://aiatlasgraph.com/t/naturalexperiments.md) › Różnica w różnicach (difference-in-differences)

## Description

- PL: Estymator porównujący zmianę wyniku w czasie w grupie objętej interwencją ze zmianą w grupie kontrolnej, przy założeniu równoległych trendów.
- EN: An estimator comparing the change over time in the treated group with the change in a control group, assuming parallel trends.

## In one sentence

- PL: Porównujesz, jak zmieniła się sytuacja w miejscu objętym zmianą i w podobnym miejscu bez niej, przed i po.
- EN: You compare how things changed in a place affected by a change and in a similar place without it, before and after.

## Problem it solves

- PL: Wyniki rosną lub spadają same z siebie, np. przez sezon, więc samo porównanie przed i po myli skutek ze zbiegiem okoliczności.
- EN: Outcomes rise or fall on their own, for example with the seasons, so a simple before-and-after comparison mistakes coincidence for effect.

## What it does

- PL: Odejmuje zmianę, która i tak zaszła w grupie porównawczej, od zmiany w grupie objętej działaniem; zostaje to, co dodało samo działanie.
- EN: It subtracts the change that happened anyway in the comparison group from the change in the affected group, leaving what the action added.

## Everyday example

- PL: Sklep wprowadza dostawę tego samego dnia w jednym mieście. Porównujesz wzrost zamówień tam ze wzrostem w podobnym mieście bez tej usługi.
- EN: A shop launches same-day delivery in one city. You compare the rise in orders there with the rise in a similar city without the service.

## This concerns you if you…

- PL: zmiana objęła tylko część regionów lub klientów
- PL: masz dane z okresu przed zmianą i po niej
- EN: a change reached only some regions or customers
- EN: have data from before and after the change

## Keywords

parallel trends · event study · two-way fixed effects · staggered adoption · Callaway-Sant'Anna · synthetic difference-in-differences · pre-trends · panel data

## How it works

- PL: W układzie 2×2 efekt to (po − przed) w grupie leczonej minus (po − przed) w kontrolnej; równoważnie współczynnik interakcji grupa × okres w regresji. Kluczowe założenie to równoległe trendy bez interwencji, sprawdzane wykresem okresów sprzed zmiany (event study). Przy wdrażaniu w różnych terminach klasyczna regresja z dwukierunkowymi efektami stałymi bywa obciążona, stąd nowsze estymatory.
- EN: In the 2×2 case the effect is (after − before) for the treated minus (after − before) for controls, equivalently the group × period interaction in a regression. The key assumption is parallel trends absent treatment, probed by plotting pre-period estimates (event study). With staggered adoption, classic two-way fixed-effects regression can be biased, motivating newer estimators.

## Limits

- PL: Równoległych trendów po interwencji nie da się zweryfikować; zmiany kierowane do słabnących regionów łamią to założenie. Inne wydarzenia w tym samym czasie zakłócają wynik. Przy różnych terminach wdrożenia i zmiennych w czasie efektach zwykła regresja daje mylące średnie.
- EN: Post-treatment parallel trends cannot be verified; changes targeted at declining regions break the assumption. Concurrent events contaminate the result. With staggered timing and time-varying effects, standard regression yields misleading averages.

## Key terms

- PL: **równoległe trendy**: Bez zmiany obie grupy rozwijałyby się w tym samym tempie.
- PL: **event study**: Wykres efektu okres po okresie, także przed zmianą.
- PL: **wdrożenie rozłożone w czasie**: Różne grupy dostają zmianę w różnych terminach.
- EN: **parallel trends**: Without the change both groups would have moved at the same pace.
- EN: **event study**: A period-by-period plot of the effect, including before the change.
- EN: **staggered adoption**: Different groups receive the change at different times.

## Know first

- [Regresja liniowa i logistyczna (Linear and logistic regression)](https://aiatlasgraph.com/t/linearmodels.md)
- [Wyniki potencjalne i eksperymenty z losowaniem (Potential outcomes and randomised experiments)](https://aiatlasgraph.com/t/potentialoutcomes.md)

## Related topics

Untyped, symmetric "see also" links.

- [Metoda syntetycznej kontroli (Synthetic control method)](https://aiatlasgraph.com/t/syntheticcontrol.md)

## Sources

- [Matheus Facure · Causal Inference for the Brave and True (online handbook with Python code)](<https://matheusfacure.github.io/python-causality-handbook/>) `facure-brave-true` · by Matheus Facure
- [Scott Cunningham · Causal Inference: The Remix (2nd edition of “The Mixtape”, online version)](<https://mixtape.scunning.com/>) `cunningham-mixtape-remix` · by Scott Cunningham

---

AI Atlas revision 131 (2026-11-07) · HTML: https://aiatlasgraph.com/t/diffindiff · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-11-07
