*! version 1.0 03Sep2024
help dynamic_est

dynamic_est

dynamic_est -- Visualizing dynamic effects in TWFE models. help dynamic_est.

Syntax

dynamic_est y [if]
[,
treat(varlist)
time(varlist)
ref(integer)
absorb(string)
cluster(varlist)
cov(string)
level(string)
figname(string)
figtitle(string)
figsubtitle(string)
regtype(string)
]

where y, treat, time, ref are required.

installation

*- net install

. net install dynamic_est, from(https://mengke25.github.io/files/function/stata/dynamic_est) replace

Description

simplifies the visualization of dynamic effects in two-way fixed effects (TWFE) models. It is ideal for use in event
study or Difference-in-Differences (DID) analyses. This command allows users to visualize time-varying effects by
specifying key regression parameters and reference points.

y(varlist) (required) – The dependent variable.

treat(varlist) (required) – A binary or intensity variable indicating the treatment assignment.

time(varlist) (required) – The time variable in the panel dataset, it can be natural time or relative time.

ref(integer) (required) – The reference period for the dynamic analysis.

absorb(string) (optional) – The fixed effects or control variables to be absorbed.

cov(string) (optional) – Covariates to be included in the model.

cluster(varlist) (optional) – The clustering variable.

level(string) (optional) – Confidence level for confidence intervals (default is 90). Options: 90, 95, 99.

regtype(string) (optional) – Regression type, either reg (OLS, default) or ppml (Poisson Pseudo Maximum Likelihood).

figname(string) (optional) – Name for the output graph.

figtitle(string) (optional) – Title for the figure.

figsubtitle(string) (optional) – Subtitle for the figure.

Examples

*- Run example1

standard-DID-specifaction

. use sample1.dta, clear

. dynamic_est lnv , treat(treat) time(year) ref(2009)

*- Run example2

standard-DID-specifaction

. use sample1.dta, clear

. dynamic_est lnv , treat(treat_intens) time(year) ref(2009) absorb(id year) cluster(id) regtype(reg)

*- Run example3

standard-DID-specifaction

. use sample1.dta, clear

. dynamic_est v , treat(treat) time(year) ref(2009) absorb(id year) cluster(id) regtype(ppml) figname(fig) figtitle(my fig)

*- Run example4

staggered-DID-specifaction

. use sample2.dta, clear

. dynamic_est lnv , treat(treat) time(t) ref(-1)

*- Run example5

staggered-DID-specifaction

. use sample2.dta, clear

. dynamic_est lnv , treat(treat_intens) time(t) ref(-1) absorb(id year) cluster(id)

Author

MengKe China Institute for WTO studies, University of International Business and Economics, China.

E-mail: uibemk@126.com.

Blog: mengke25.github.io