eventshape

A stata program that reshapes data with multiple policy changes within a jurisdiction to be ready for event study analyses.

Installation
Install eventshape by opening Stata and running the command:

net install eventshape, from(http://kylerozema.com/eventshape)

The documentation for eventshape is included with the installation. To read the documentation, run the command:

help eventshape


Background
Event studies are power research designs when treatments are staggered in time across individuals or across other observations such as states. Take the example of state policy changes. The key feature is that one state might have a policy change on, say, July 1, 2000 and another state might have the same policy change on January 1, 2002. The fact that two states have policy changes at different times is useful in terms of counterfactuals: we can use the treated states as counterfactuals for each other. We can exploit these changes to help identify short term effects of the policy change on an outcome of interest. Reshaping data for event studies when the policy change occurs to each state only once is straightforward. Define the event time as calendar time minus the date of treatment for each treated observation, i.e, where the date of the policy change becomes event time 0. Using event time under this definition stacks the data in a manageable way to then collapse the data and compute statistics of interest.


Technical Description
Reshaping data for event studies when policies change multiple times within one or more states is not straightforward. The familiar scenario for public finance economists, health economists, and public health researchers is state cigarette taxes. Since the early 90's, some states have raised their cigarette taxes more than five times. The issue with reshaping this sort of data for an event study is that there are multiple "events" for each state, where event in this example is change in state cigarette taxes. For researchers confronted with this and similar problems, eventshape is a solution. Simply rename the policy variable of interest (here, cigarette taxes) to policy, rename the jurisdiction variable of interest (usually state) to juris, make sure the date variable is denoted by a four digit year variable named year and the one or two digit month variable named month, and send the following command to stata: eventshape year month juris policy. That it is!

eventshape creates the following two variables: (1) event_time, which is the event time where the change in the policy in the jurisdiction is at event_time = 0; and (2) id, which is a unique identifier for each event within the event study, that is, it uniquely identifies each change in policy and the 6 months before and after the change in policy.


Notes:
(1) eventshape deletes all observations that are not within +/-6 months of a policy change.
(2) eventshape is only a one way conversion.
(3) Researcher may use the preserve and restore commands to convert data back to original data.


Example:

In the table on the right below, the dashed rows ( - - - - - - ) indicate that eventshape has deleted the observation.
Original Data (before eventshape)
state year month tax
________________________________________
MI 2005 9 0.5
MI 2005 10 0.5
MI 2005 11 0.5
MI 2005 12 0.5
MI 2006 1 0.5
MI 2006 2 0.5
MI 2006 3 0.5
MI 2006 5 0.5
MI 2006 6 1
MI 2006 7 1
MI 2006 8 1
MI 2006 9 1
MI 2006 10 1
MI 2006 11 1
MI 2006 12 1
MI 2007 1 1
MI 2007 2 1
MI 2007 3 1
MI 2007 4 1
MI 2007 5 1
MI 2007 6 1
MI 2007 7 1
MI 2007 8 1
MI 2007 9 1
MI 2007 10 2.8
MI 2007 11 2.8
MI 2007 12 2.8
MI 2008 1 2.8
MI 2008 2 2.8
MI 2008 3 2.8
MI 2008 4 2.8
MI 2008 5 2.8
MI 2008 6 2.8









eventshape
------------------>
Data after eventshape
state id event_time tax
________________________________________
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MI 1 -6 0.5
MI 1 -5 0.5
MI 1 -4 0.5
MI 1 -3 0.5
MI 1 -2 0.5
MI 1 -1 0.5
MI 1 0 1
MI 1 1 1
MI 1 2 1
MI 1 3 1
MI 1 4 1
MI 1 5 1
MI 1 6 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MI 2 -6 1
MI 2 -5 1
MI 2 -4 1
MI 2 -3 1
MI 2 -2 1
MI 2 -1 1
MI 2 0 1
MI 2 1 2.8
MI 2 2 2.8
MI 2 3 2.8
MI 2 4 2.8
MI 2 5 2.8
MI 2 6 2.8
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -