I've seen this mentioned often in papers, but I never fully got what it means. Below I simulating some diff-in-diff type of data with Stata.

How would a "linear trend" be included in a two-way fixed-effects regression?

** make some random data
set seed 35135
clear all
set obs 10000
gen id = ceil(_n/30)
bysort id: gen t = _n
bysort id: gen D = (id>200 & t>15)
gen y = abs(int(rnormal() * 1000))
gen x = floor(abs(rlogistic()) * 15 + abs(rlogistic() * 5))
bysort id (x): replace x = x[_N]

label var id "group"
label var t "time"
label var D "treated"
label var y "outcome"
label var x "control"

** Some DiD regression
reg y i.D#i.t i.t i.id, robust


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.