Difference-in-Differences (DID or DiD) analysis is a quasi-experimental statistical method
used to estimate the causal effect of an intervention, policy, treatment, or event when
randomization is not possible.
It compares:
• the change over time in an outcome for a treatment group
with
• the change over time in the same outcome for a control group.
The key idea is:
If the treatment had no effect, the treatment group and control group would have followed
similar trends over time.
1. Basic Idea of DID
Suppose a government introduces a livestock vaccination program in one district but not another.
You measure poultry mortality:
• Before the vaccination
• After the vaccination
for both:
• Treated district
• Untreated district
DID estimates:
[
\text{DID Effect}
(\text{After}_T - \text{Before}_T)
(\text{After}_C - \text{Before}_C)
]
Where:
• (T) = Treatment group
• (C) = Control group
Formula Illustration
Suppose mortality rates are:
Group Before After Change
Treatment 20 8 -12
Control 18 14 -4
Then:
[
\text{DID} = (-12) - (-4) = -8
]
Interpretation:
• Mortality reduced by 8 units more in the treated group than in the control group.
• Estimated treatment effect = -8.
2. DID Regression Model
The standard DID regression is:
Y_{it}=\beta_0+\beta_1T_i+\beta_2Post_t+\beta_3(T_i\times Post_t)+\varepsilon_{it}
Where:
• (Y_{it}) = outcome variable
• (T_i) = 1 if treatment group, 0 otherwise
• (Post_t) = 1 for post-treatment period, 0 for pre-treatment
• (T_i \times Post_t) = interaction term
• (\beta_3) = DID estimator (treatment effect)
3. Main Assumptions of DID
(A) Parallel Trends Assumption (Most Important)
Before treatment, the treatment and control groups should follow similar trends over time.
Formally:
[
E[Y^0_{T,after}-Y^0_{T,before}]
E[Y^0_{C,after}-Y^0_{C,before}]
]
Meaning:
• Without treatment, both groups would have changed similarly.
Why Important
If groups already had different trends before treatment, DID becomes biased.
Example of Violation
Suppose:
• poultry mortality was already decreasing rapidly in treated farms before vaccination,
• but stable in control farms.
Then the reduction after treatment may not be caused by the vaccination.
(B) No Simultaneous Confounding Events
No other event should affect only one group during the study period.
Example
Bad case:
• Treatment district receives vaccination
• At same time receives subsidized feed
Then DID cannot separate the two effects.
(C) Stable Group Composition
The composition of groups should remain relatively stable over time.
Problem
If many weak farms leave the treatment group after intervention, results may be misleading.
(D) No Spillover Effects (SUTVA)
Treatment applied to one group should not affect the control group.
Example
If vaccinated birds mix with non-vaccinated birds and reduce disease spread in the control area,
the control group is contaminated.
(E) Common Timing Structure
Treatment and control groups should be observed during comparable time periods.
4. Data Requirements / Data Properties for
DID
DID requires specific data structure.
Minimum Requirement
You need:
Group Time
Treatment group Before and after
Control group Before and after
This creates a 2 × 2 structure.
5. Types of Data Suitable for DID
(A) Panel (Longitudinal) Data — Best Option
Same individuals/farms/households measured repeatedly over time.
Example
Farm ID Year Vaccination Mortality
1 2024 0 20
1 2025 1 8
2 2024 0 18
2 2025 1 9
Advantages:
• Controls for unobserved fixed characteristics
• Stronger causal inference
(B) Repeated Cross-Sectional Data
Different individuals sampled before and after.
Example
2024 survey:
• random sample of farms
2025 survey:
• another random sample of farms
Still usable if groups are comparable.
6. Variables Required in DID Dataset
A DID dataset usually needs:
Variable Purpose
Outcome variable Dependent variable
Treatment indicator Treatment vs control
Time indicator Before vs after
Interaction term DID effect
Covariates (optional) Control variables
7. Example of Suitable DID Dataset
Example: Ethnoveterinary Treatment Study
Suppose you want to evaluate whether an ethnoveterinary medicine reduces Newcastle disease
mortality.
Study Design
Group Treatment
Group A Receives EVM
Group B No EVM
Mortality measured:
• Before outbreak
• After outbreak
Example Dataset
Farm Time EVM Mortality
1 Before 1 25
Farm Time EVM Mortality
1 After 1 10
2 Before 1 22
2 After 1 9
3 Before 0 24
3 After 0 18
4 Before 0 23
4 After 0 19
This is appropriate for DID.
8. Situations Where DID Is Commonly Used
DID is heavily used in:
Field Example
Economics Minimum wage policy
Public health Vaccination programs
Agriculture Improved feed intervention
Education New teaching policy
Epidemiology Disease control measures
Social sciences Welfare policy evaluation
9. Advantages of DID
Advantage Explanation
Controls for fixed unobserved differences Removes time-invariant bias
Stronger than simple before-after comparison Uses control group
Useful when randomization impossible Quasi-experimental
Simple interpretation Difference of changes
10. Limitations of DID
Limitation Explanation
Relies heavily on parallel trends Hard to verify perfectly
Sensitive to confounding events External shocks bias estimates
Spillovers can bias results Contamination issue
Requires good pre-treatment data Especially for trend checking
11. How to Check Parallel Trends
Researchers usually:
• Plot outcome trends before treatment
• Compare slopes visually
• Run placebo/pre-trend tests
Example:
If treatment and control mortality rates move similarly before intervention, assumption is more
plausible.
12. Extended DID Designs
Modern DID can include:
Extension Description
Multiple time periods Several years before/after
Multiple treatment groups Different intervention intensities
Staggered adoption Treatment starts at different times
Triple differences (DDD) Adds third comparison dimension
13. Simple Interpretation of DID
DID answers:
“Did the treatment group improve more (or worsen less) than the control group over time?”
That is the core logic.
14. Summary
DID is appropriate when:
✔ There is a treatment and control group
✔ Data exist before and after intervention
✔ Randomization is absent or difficult
✔ Parallel trends assumption is plausible
Essential Assumptions
1. Parallel trends
2. No simultaneous shocks
3. Stable group composition
4. No spillover effects
5. Comparable timing
Best Data Type
• Panel/longitudinal data is strongest
• Repeated cross-sectional data can also work