Title

flexpaneldid_preprocessing - Data preprocessing for flexpaneldid

Syntax

flexpaneldid_preprocessing,
id(varname)
treatment(varname)
time(varname)
matchvars(varlist) matchtimerel(integer)
[matchvarsexact(varlist) prepdataset(string) replace]

options

id(varname) name of the panel id variable

treatment(varname) name of the treatment variable

time(varname) name of the time variable

matchvars(varlist) list of matching variables

matchtimerel(integer) definition of matching time in relation to treatment start

matchvarsexact(varlist) list of exact matching variables

prepdataset(filename) filename of preprocessed dataset

Description

flexpaneldid is a Stata package for causal analysis of treatments with varying start dates and varying treatment durations within panel data with more than two observation times. It consists of two commands based on each other,
flexpaneldid_preprocessing and
flexpaneldid. In the
flexpaneldid_preprocessing, the original data set is rearranged in that individual selection groups for every treated unit are created which contain all potential controls. The result of this preprocessing is a temporary dataset with information that are crucial for the use of
flexpaneldid.

Based on the temporary data set,
flexpaneldid estimates the average treatment effect for the treated. For this step, different matching approaches are available. Additionally, quality and robustness checks can be conducted.

The flexpaneldid package requires the installation of the Stata ado-files psmatch2, pstest and cem, which are used in the flexpaneldid command.

Arguments

Main

id(varname) uniquely identifies objects in the panel dataset. The variable must be an integer or string.

treatment(varname) contains the variable defining the treatment. Input must be in 0-1 format.

IMPORTANT NOTE: The variable must equal to one for the whole treatment phase. In case of repeated treatments for
one unit (identified by a unique id), the repeated treatments are handled as one treatment phase.

time(varname) identifies the time information in the panel. Input must be an integer indicating an absolute time, e. g. year, month, quarter.

IMPORTANT NOTE: If the data contain only information in date-format, this information must be converted into an integer.

matchvars(varlist)} should contain all variables that may be used for matching.

matchtimerel(int) is a relative time specification (in relation to the treatment start) that defines the time of matching;
default = 0 (if no matching time is defined). In this case, flexpaneldid_preprocessing uses variable values observed at the treatment start.

IMPORTANT NOTE: The dimension of the parameter in brackets depends on the dimension of time that is defined for time().
For example, matchtimerel(-1) means that the matching process is conducted one year before the treatment starts, if the dimension of the time variable is years.

Options

matchvarsexact(varlist) indicates those variables that are used for exact matching. Exact matching variables are applied already at the preprocessing step.

prepdataset(string) replace specifies the path where the data set containing the preprocessing result is stored. replace overwrites any existing data set with the new data. We highly recommend the use of this option, since this file is a required argument for flexpaneldid. Otherwise you have to manually save the output dataset.

Output

After preprocessing the dataset is no longer in a panel structure. Every observation represent an id at matchtimerel(), where the exact matching selects the potential controls for every treated into a "selection group".

id id variable as defined in id() option

selection_goup all potential controls, exact matched to a treated, are in the same selection group

treated dummy variable for treated(1) / non treated(0)

first_treatment first treatment time of treated, valid for whole selection group

last_treatment last treatment time of treated, valid for whole selection group

matchvars all variables defined in matchvars() at matchtimerel()

Stored results

flexpaneldid_preprocessing saves the following in r():

Scalars

r(treated) number of unique treated id in initial dataset

r(treated_dropped) number of unique treated id dropped during preprocessing

r(treated_kept) number of unique treated id after preprocessing

r(group_size_mean) mean size of selection groups after exact matching

Example

. use flexpaneldid_example_data.dta, clear

. flexpaneldid_preprocessing, id(cusip) treatment(treatment) time(year) matchvars(employ stckpr rnd sales return pats_cat rndstck_cat rndflt_cat) matchtimerel(-1) matchvarsexact(sic_cat) prepdataset("preprocessed_data.dta") replace

Also see

flexpaneldid

Authors

Eva Dettmann, Halle Institute for Economic Research (IWH), eva.dettmann@iwh-halle.de

Alexander Giebler, Halle Institute for Economic Research (IWH), alexander.giebler@iwh-halle.de

Antje Weyh, Institute for Employment Research (IAB), antje.weyh@iab.de

Thanks for citing the toolbox as follows

E. Dettmann, A. Giebler and A. Weyh. (2020). flexpaneldid. A Stata toolbox for causal analysis with varying treatment time and duration.

https://ideas.repec.org/p/zbw/iwhdps/32020.html