> ## Content Index
> Fetch the complete content index at: https://bongholee.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Difference in Difference
- URL: https://bongholee.com/difference-in-differences/
- Published: 2022-10-29T00:54:54.000Z
- Updated: 2022-10-29T01:14:50.000Z
- Author: Bongho Lee
- Tags: Causal Inference, #Import 2026-11-22 06:32

> 쟤는 키가 저렇게 컸는데 난 왜 이러지? - 사춘기 소녀 멘토링(상큼발랄 블링걸스) 中

# Why Difference in Difference?

- Online Marketing → Effectiveness 측정이 쉽다.
- Offline Marketing(billboard or TV Campaign) → 측정이 어렵다.
- Difference in Difference(Diff in Diff or DiD) → Macro interventions의 Effect를 측정

# DiD Estimator

- $\\hat{ATET} = E\[Y\_1(1) - Y\_0(1) | D=1\]$  
  - $Y\_0(1)$은 Counterfactual
- $\\hat{ATET} = E\[Y(1)| D=1\] - E\[Y(1) | D=0\]$으로 치환  
  - $E\[Y\_0(1) | D=1\] = E\[Y\_1(0) | D=1\] + (E|Y\_0(1)|D=01\] - E\[Y\_0(0)|D=0\])$  
    - Treatment 이전 시점 수치에서 Control Group의 T=0대비 T=1시점 상승한 수치를 빼는 형태
- 재정리하면 다음과 같다  
  - $\\hat{ATET} =(E\[Y(1)|D=1\] - E\[Y(1)|D=0\]) - (E\[Y(0)|D=1\] - E\[Y(0)|D=0\]) $
- 회귀식으로 풀면 다음과 같이 볼 수 있다.  
  - $Y\_i = \\beta\_{0} + \\beta\_{1}I\_i + \\beta{2}T\_i + \\beta\_{3}I\_i\*T\_i + e\_i$
  - 이 때 $\\beta\_{3}$이 DiD estimator로 볼 수 있다.
  - $\\beta\_{0}$은 Control Group의 Baseline
  - $\\beta\_{0} + \\beta\_{1}$은 Treatment Group의 Baseline
  - $\\beta\_{0} + \\beta\_{2}$은 Control Group의 Intervention Period 이후 수치를 보기 위한 부분
  - $\\beta\_{2}$ Control Group의 Trend에 따른 증가수치

# Parallel Trend Assumption

- Control Group과 Treatment Group이 동일한 Trend를 가지고 있어야 한다.
- 하지만 그렇지 않은 경우들이 있다.  
  - Rnadom Data가 아닌경우 → Treatment Group 결정시 예상반응율에 기반해서 했다든가, 또는 그 반대일 경우
  - Group간 Trend가 완연히 다르게 나타나는 경우

# Alternatives

- Synthetic Control이 있음  
  - Multiple Group을 결합해서 Synthetic Control Group을 만든다. 이 때 이 Group은 Treatment Group의 Trend와 비슷해서 Parallel Trend Assumption을 만족시켜야 한다.
  - [Nick Jones, Sam Barrows: Uber's Synthetic Control | PyData Amsterdam 2019](https://www.youtube.com/watch?v=j5DoJV5S2Ao&ref=bongholee.com)
  - [Using Causal Inference to Improve the Uber User Experience](https://www.uber.com/en-US/blog/causal-inference-at-uber/?ref=bongholee.com)

# References

- [13 - Difference-in-Differences](https://matheusfacure.github.io/python-causality-handbook/13-Difference-in-Differences.html?ref=bongholee.com)
- [What’s Trending in Difference-in-Differences? A Synthesis of the Recent Econometrics Literature∗](https://arxiv.org/pdf/2201.01194.pdf?ref=bongholee.com)
- [Difference-in-Differences Methodology](https://andrewcbaker.netlify.app/2019/09/25/difference-in-differences-methodology/?ref=bongholee.com)