*! version 3.1.0 July 11 2024
help get_unit_time_effects

Title

get_unit_time_effects -- Generate Group and Time Effects in a Repeated Cross-Sectional Dataset

Syntax

get_unit_time_effects
depvar [indepvars]
[if] [in] [weight]
,
panelvar(varname)
timevar(varname)
[options]

Main
panelvar(varname) variable that identifies the groups

timevar(varname) variable that identifies the time periods

saving(filename, [replace]) save results to filename

nooutput omit regression table

clear replace data in memory with the unit-time effects file

depvar and indepvars may contain time-series operators; see tsvarlist.

depvar and indepvars may contain factor variables; see fvvarlist.

* indepvars should contain covariates that vary at the individual level.

Description

get_unit_time_effects estimates group-time fixed effects in a repeated cross-sectional dataset. It produces a Stata data file with the
variables panelvar, timevar, and _unittimeeffects. The variable _unittimeeffects contains the group-time effects. Hansen (2007)
describes a two-step procedure to obtain the coefficient estimates of covariates that vary at the group level within a repeated
cross-sectional framework. The two-step procedure can be used to obtain the coefficient estimates of an event-study when the data
is repeated cross-sectional. get_unit_time_effects implements the first part of the two-step procedure. Then, xtevent can
be used for the second part of the procedure to obtain the event-study coefficient estimates. See xtevent.

Options

panelvar(varname) specifies the group variable. The policy variable should vary at this group level.

timevar(varname) specifies the time variable.

saving(filename, [replace]) specifies the name of the Stata data file to store the unit-time effects estimates. If saving is
not specified, the file will be saved in the current directory with the name unit_time_effects.dta. The suboption replace overwrites
the unit-time effects file.

nooutput omits the regression table.

clear replaces the dataset in memory with the unit-time effects file.

Examples

Load example repeated cross-sectional dataset

. use "https://github.com/JMSLab/xtevent/blob/main/test/small_repeated_cross_sectional_example31.dta?raw=true", clear

. xtset, clear

Get unit-time effects and save them as a dta file with the name and directory indicated through the saving option. Add the
replace suboption to overwrite the file.

. get_unit_time_effects y u eta, panelvar(state) timevar(t) saving("effect_file.dta", replace)

Proceed with xtevent

. bysort state t (z): keep if _n==1

. keep state t z

Merge with the file that was created with get_unit_time_effects

. merge m:1 state t using effect_file.dta

. drop _merge

Use xtevent to estimate an event-study

. xtevent _unittimeeffects, panelvar(state) t(t) policyvar(z) window(5)

. xteventplot

Authors

Simon Freyaldenhoven, Federal Reserve Bank of Philadelphia.

simon.freyaldenhoven@phil.frb.org

Christian Hansen, University of Chicago, Booth School of Business.

chansen1@chicagobooth.edu

Jorge Pérez Pérez, Banco de México.

jorgepp@banxico.org.mx

Jesse Shapiro, Harvard University and NBER.

jesse_shapiro@fas.harvard.edu

Support

For support and to report bugs please email Jorge Pérez Pérez, Banco de México.

jorgepp@banxico.org.mx

xtevent can also be found on GitHub.

References

Hansen, C. (2007). "Generalized Least Squares Inference in Panel and Multilevel Models
with Serial Correlation and Fixed Effects" Journal of Econometrics, 140(2), 670-694.