Skip to content

Commit

Permalink
PR for 109 xtevent 220 (#146)
Browse files Browse the repository at this point in the history
* #109 Update from main (#145)

* PR for #111: drop of collinear variables (#112)

* #111 use _rmcoll to check collinearity

* #111 collinearity among the event-time dummies

* #111 consider combinations of event-time dummies

* PR for #108: warning if robust se (#117)

* #108 add warning when robust is specified

* #108 correct a typo

* #108 edit the warning message

* Add files via upload

* #108 remove comment

* Add files via upload

* #108 remove comment

* PR for #113: examples without collinearity (#115)

* #113 examples without collinearity

* #113 help files' examples without collinearity

* #113 add collinearity example to test file

* #116 specify normalization to zero (#118)

* PR for #103: emphasize impute option (#121)

* #103 emphasize impute option on homepage

* #103 github doesn't support font colors

* #103 alternative for not allowing colors

* #103 add note about impute option

* #103 update link to note about impute

* #103 correct typo

* #103 edit bullet about impute option

* #103 indicate markstat to create the html file

* #103 delete issue folder

* PR for #114: proxyiv doesnt allow varnames (#122)

* #114 loop over only numbers

* #114 case when no lead order is specified

* #114 remove comment

* #114 normalize one coeff per external instrument

* #114 edit error message

* #114 examples to check implementation

* #114 examples' log file

* #114 edit normalization messages

* #114 examples to check changes

* #114 correct examples

* #122 Erase issue folder

Co-authored-by: Jorge Eduardo Perez Perez <[email protected]>

* PR for #35: implement estimation robust treatment heterogeneity (#124)

* #35 Create experimental file

* #35 Create indicator for never-treated

* #35 Estimate basic event study

* #35 Implement Sun's suggested event study plot

* #35 compare sun_abraham vs EventStudyInteract

* #35 include imputation of the endpoints

* #35 embed EventStudyInteract into xtevent

* #35 enable postestimation options

* #35 examples to check implementation

* #35 cohort effects and save interactions

* #35 add examples

* #35 examples' log file

* #35 delete to update examples

* #35 suboption to save the interactions

* #35 update examples to check implementation

* #35 example with treatment heterogeneity data

* #35 add examples to help file

* #35 add example to the home page

* #35 add examples to test file

* #35 edit the help file

* #35 message about SA's estimator

* #35 examples and check with larger dataset

* #35 specify needed option for SA in help file

* #35 add reference's year

* #35 examples controlling for eta

* #35 description for suboption to save interactions

* #35 add avar as a dependency

* #35 compare imputation rules

* #35 change title of SA's examples in readme

* #35 add depedencies' versions

* #35 delete issue folder

* #35 cite as SA estimator instead of IW estimator

* #35 use _regress to compute cohort weights

* #35 check if avar is installed

* #35 check of existing interaction variables

* #35 wording of Sun and Abraham explanation

* #35 specify that avar is needed

* #35 typo control cohort

* #35 comment about scaling factor

* #35 typo scaling factor

* #35 remove extra space

* #35 specify opt instead of cmd

Co-authored-by: rayhuang11 <[email protected]>

* Issue 59 allow for data structures that cannot be xtseted (#127)

* #59 Create issue folder

* #59 Add dataset creation dofile to issue folder

* #59 Two step estimation

* #59 increase number of obs per state-time cell

* #59 Upload data generation example

* #59 create large version of Example31

* #59 larger version of Example31

* #59 large version of repeated cross-sectional data

* #59 estimation for different sample sizes

* #59 compare estimation time

* #59 one-step estimation with repeated-cs data

* #59 small version of repeated-cs

* #59 test the implementation

* #additions and corrections to the 1st approach

* #59 additions and corrections to the 1st approach

* #59 implement 2nd approach

* #59 delete small version dataset

* #59 upload small repeated-cs dataset

* #59 check need of touse

* #59 estimate FE with areg

* #59 edit get_unit_time_effects' help file

* #59 option to replace dataset in memory

* #59 describe load option

* #59 implement repeated cs in IV setting

* #59 delete examples old file

* #59 examples to check implementation

* #59 add examples to test file

* #59 add repeatedcs data to test folder

* #59 new data url in help file

* #59 describe repeatedcs option in help file

* #59 remove get_unit_time_effects from issue folder

* #59 remove get_unit_time_effects help file

* #59 place get_unit_time_effects in xtevent folder

* #59 make get_unit_time_effects downloadable

* #59 saving option and documentation inside code

* #59 option saving and documentation inside code

* #59 enable in static versions

* #59 update examples to check implementation

* #59 option saving in test file's examples

* #59 check saving in execution time

* #59 correct typos and wording

* #59 flexible number of leads to test

* #59 static examples

* #59 quiet generation of leads

* #127 fix eventiv brace bug

* #127 Minor changes to test file

* #127 Default to -reghdfe- for fixed effects estimation in repeatedcs

* #127 Informative varname for imputed policyvar in static estimation

* #127 Informative varname in getunittimeeffects

* #127 Minor help file changes for getunittimeeffects

* #127 erase absorbed var in getunittimeeffects

* #127 Delete issue folder

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

* Issue126 excluding units but eventtime is defined (#139)

* #126 verify the bug

* #126 remove sample marker

* #126 example after correction

* #126 dataset to verify the bug

* #126 marksample with missings in policyvar and eta

* #126 no marksample with missings in z and eta

* #126 with marksample and missings in z and eta

* #126 without marksample and missings in z and eta

* #126 with marksample and missings in z

* #126 with marksample and missings in z

* #126 without marksample and missings in z

* #126 test file with missing values

* #126 separate marksample for _eventgenvars

* #126 Tempvar generation for mark

* Update 126 from main (#140)

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Add mark to xtevent.ado

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Delete issue folder

* 136 check smoothest line solution (#142)

* #136 Create issue folder

* #136 Upload markdown

* #136 Update xteventplot.ado

* #136 Upload test log

* #136 Upload data and plots

* #136 Update from main  (#141)

* #137 Fix bug in static estimation without imputation (#138)

* Issue126 excluding units but eventtime is defined (#139)

* #126 verify the bug

* #126 remove sample marker

* #126 example after correction

* #126 dataset to verify the bug

* #126 marksample with missings in policyvar and eta

* #126 no marksample with missings in z and eta

* #126 with marksample and missings in z and eta

* #126 without marksample and missings in z and eta

* #126 with marksample and missings in z

* #126 with marksample and missings in z

* #126 without marksample and missings in z

* #126 test file with missing values

* #126 separate marksample for _eventgenvars

* #126 Tempvar generation for mark

* Update 126 from main (#140)

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Add mark to xtevent.ado

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Delete issue folder

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #136 Upload plot testing file

* #136 Do not display path when optimization fails

* #142 Delete issue folder

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* PR for Issue120 integrate impute documentation (#144)

* #120 documentation of the impute option

* #120 Update from main (#143)

* PR for #103: emphasize impute option (#121)

* #103 emphasize impute option on homepage

* #103 github doesn't support font colors

* #103 alternative for not allowing colors

* #103 add note about impute option

* #103 update link to note about impute

* #103 correct typo

* #103 edit bullet about impute option

* #103 indicate markstat to create the html file

* #103 delete issue folder

* PR for #114: proxyiv doesnt allow varnames (#122)

* #114 loop over only numbers

* #114 case when no lead order is specified

* #114 remove comment

* #114 normalize one coeff per external instrument

* #114 edit error message

* #114 examples to check implementation

* #114 examples' log file

* #114 edit normalization messages

* #114 examples to check changes

* #114 correct examples

* #122 Erase issue folder

Co-authored-by: Jorge Eduardo Perez Perez <[email protected]>

* PR for #35: implement estimation robust treatment heterogeneity (#124)

* #35 Create experimental file

* #35 Create indicator for never-treated

* #35 Estimate basic event study

* #35 Implement Sun's suggested event study plot

* #35 compare sun_abraham vs EventStudyInteract

* #35 include imputation of the endpoints

* #35 embed EventStudyInteract into xtevent

* #35 enable postestimation options

* #35 examples to check implementation

* #35 cohort effects and save interactions

* #35 add examples

* #35 examples' log file

* #35 delete to update examples

* #35 suboption to save the interactions

* #35 update examples to check implementation

* #35 example with treatment heterogeneity data

* #35 add examples to help file

* #35 add example to the home page

* #35 add examples to test file

* #35 edit the help file

* #35 message about SA's estimator

* #35 examples and check with larger dataset

* #35 specify needed option for SA in help file

* #35 add reference's year

* #35 examples controlling for eta

* #35 description for suboption to save interactions

* #35 add avar as a dependency

* #35 compare imputation rules

* #35 change title of SA's examples in readme

* #35 add depedencies' versions

* #35 delete issue folder

* #35 cite as SA estimator instead of IW estimator

* #35 use _regress to compute cohort weights

* #35 check if avar is installed

* #35 check of existing interaction variables

* #35 wording of Sun and Abraham explanation

* #35 specify that avar is needed

* #35 typo control cohort

* #35 comment about scaling factor

* #35 typo scaling factor

* #35 remove extra space

* #35 specify opt instead of cmd

Co-authored-by: rayhuang11 <[email protected]>

* Issue 59 allow for data structures that cannot be xtseted (#127)

* #59 Create issue folder

* #59 Add dataset creation dofile to issue folder

* #59 Two step estimation

* #59 increase number of obs per state-time cell

* #59 Upload data generation example

* #59 create large version of Example31

* #59 larger version of Example31

* #59 large version of repeated cross-sectional data

* #59 estimation for different sample sizes

* #59 compare estimation time

* #59 one-step estimation with repeated-cs data

* #59 small version of repeated-cs

* #59 test the implementation

* #additions and corrections to the 1st approach

* #59 additions and corrections to the 1st approach

* #59 implement 2nd approach

* #59 delete small version dataset

* #59 upload small repeated-cs dataset

* #59 check need of touse

* #59 estimate FE with areg

* #59 edit get_unit_time_effects' help file

* #59 option to replace dataset in memory

* #59 describe load option

* #59 implement repeated cs in IV setting

* #59 delete examples old file

* #59 examples to check implementation

* #59 add examples to test file

* #59 add repeatedcs data to test folder

* #59 new data url in help file

* #59 describe repeatedcs option in help file

* #59 remove get_unit_time_effects from issue folder

* #59 remove get_unit_time_effects help file

* #59 place get_unit_time_effects in xtevent folder

* #59 make get_unit_time_effects downloadable

* #59 saving option and documentation inside code

* #59 option saving and documentation inside code

* #59 enable in static versions

* #59 update examples to check implementation

* #59 option saving in test file's examples

* #59 check saving in execution time

* #59 correct typos and wording

* #59 flexible number of leads to test

* #59 static examples

* #59 quiet generation of leads

* #127 fix eventiv brace bug

* #127 Minor changes to test file

* #127 Default to -reghdfe- for fixed effects estimation in repeatedcs

* #127 Informative varname for imputed policyvar in static estimation

* #127 Informative varname in getunittimeeffects

* #127 Minor help file changes for getunittimeeffects

* #127 erase absorbed var in getunittimeeffects

* #127 Delete issue folder

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

* Issue126 excluding units but eventtime is defined (#139)

* #126 verify the bug

* #126 remove sample marker

* #126 example after correction

* #126 dataset to verify the bug

* #126 marksample with missings in policyvar and eta

* #126 no marksample with missings in z and eta

* #126 with marksample and missings in z and eta

* #126 without marksample and missings in z and eta

* #126 with marksample and missings in z

* #126 with marksample and missings in z

* #126 without marksample and missings in z

* #126 test file with missing values

* #126 separate marksample for _eventgenvars

* #126 Tempvar generation for mark

* Update 126 from main (#140)

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Add mark to xtevent.ado

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Delete issue folder

* 136 check smoothest line solution (#142)

* #136 Create issue folder

* #136 Upload markdown

* #136 Update xteventplot.ado

* #136 Upload test log

* #136 Upload data and plots

* #136 Update from main  (#141)

* #137 Fix bug in static estimation without imputation (#138)

* Issue126 excluding units but eventtime is defined (#139)

* #126 verify the bug

* #126 remove sample marker

* #126 example after correction

* #126 dataset to verify the bug

* #126 marksample with missings in policyvar and eta

* #126 no marksample with missings in z and eta

* #126 with marksample and missings in z and eta

* #126 without marksample and missings in z and eta

* #126 with marksample and missings in z

* #126 with marksample and missings in z

* #126 without marksample and missings in z

* #126 test file with missing values

* #126 separate marksample for _eventgenvars

* #126 Tempvar generation for mark

* Update 126 from main (#140)

* #128 update the imputation note's link (#129)

* #130 Fix typo (#133)

* #132 Fix bug in overid testing when overidpost was active (#134)

* 131 check that the smoothest paths wald critical value is correct (#135)

* #131 Fix Wald critical value for smoothest line

* #131 fix -polyline()- call

* #137 Fix bug in static estimation without imputation (#138)

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Add mark to xtevent.ado

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #139 Delete issue folder

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

* #136 Upload plot testing file

* #136 Do not display path when optimization fails

* #142 Delete issue folder

---------

Co-authored-by: Constantino Carreto Romero <[email protected]>

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>
Co-authored-by: rayhuang11 <[email protected]>

* #120 Update text

* #120 edit html file about imputation

* #120 Upload html to root folder

* #120 Update link to impute documentation

* #120 Render html

* #144 Delete issue folder

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>
Co-authored-by: rayhuang11 <[email protected]>

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>
Co-authored-by: rayhuang11 <[email protected]>

* #109 Update home page readme

* #109 Further updates to readme

* #109 Update version statements in ado files

* #109 Initial changes to home page examples

* #109 Remaining fix for #126 due to repeated calls to _eventgenvars in _eventiv

* #109 Further changes to example in home page readme

* #109 Fix smoothest line bug when there are multiple normalizations

* #109 Update xteventplot version date

* #109 Change xteventplot error messages and optimization output

* #109 Minor typo in homepage

* #109 Updates to help files

* #109 Update acknowledgements

* #109 Update install.txt and release.txt

---------

Co-authored-by: Constantino-Carreto-Romero <[email protected]>
Co-authored-by: rayhuang11 <[email protected]>
  • Loading branch information
3 people authored Mar 16, 2023
1 parent f399d19 commit 6051123
Show file tree
Hide file tree
Showing 12 changed files with 1,358 additions and 218 deletions.
73 changes: 43 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@
`xtevent` is a Stata package to estimate linear panel event-study models. It includes three commands: `xtevent` for estimation; `xteventplot` to create event-study plots and; `xteventtest` for post-estimation hypotheses testing.


- Last version: 2.1.1 (12aug2022)
- Last version: 2.2.0 (15mar2023)
- Current SSC version: 2.1.0 (1aug2022)
-----------

### Updates

* **Version 2.2.0 (15mar2023)**:
- Add `cohort` and `control_cohort` to obtain estimates using [Sun and Abraham's (2021)](https://www.sciencedirect.com/science/article/pii/S030440762030378X) method.
- Add `repeatedcs`option and `get_unit_time_effects`command to estimate event-studies in repeated cross-section settings.
- Add `noestimate` option to `savek()` to generate event-time dummies without estimating the regression model.
- Enable clustered and robust standard erros for IV estimation without `reghdfe`.
- Fixed bugs present in version 2.1.1.
- See [here](https://github.com/JMSLab/xtevent/releases/tag/v2.2.2) for the complete update list.

* **Version 2.1.1 (12aug2022)**:
- Fixed bugs present in xtevent 2.1.0.
- Fixed bugs present in version 2.1.0.
- Updates in the help files and other documentation.
- See [here](https://github.com/JMSLab/xtevent/releases/tag/v2.1.1) for the complete update list.

Expand All @@ -28,7 +36,7 @@
- **To produce equivalent results as with xtevent 1.0.0, where the default was to impute the endpoints, the user should use *impute(stag)*.** The **impute** option imputes missing values in the *policyvar* following different rules. For instance, specifying **impute(stag)** indicates the program to check before imputing if the *policyvar* follows staggered adoption. For a detailed explanation of the **impute** option, see this [detailed example](https://rawcdn.githack.com/JMSLab/xtevent/cf16d12f90ddf363df62c397cf0e9dc05bbd9875/impute_option_description.html).
- The option `nonstaggered` has been depreciated. The default option is now not to impute missing values or endpoints. You should now choose any of the imputation rules in the `impute` option. To get results using imputation consistent with staggered adoption, as in version 1.0.0 you should use `impute(stag)`.
- Now the option `trend` allows for trend adjustment by either OLS or GMM.
- Fixed several bugs present in version 1.0.0
- Fixed several bugs present in version 1.0.0.
- See [here](https://github.com/JMSLab/xtevent/releases/tag/v2.0.0) for the complete update list.

-----------
Expand Down Expand Up @@ -83,7 +91,7 @@ help xtevent

### Examples

Using xtevent 2.1.1
Using xtevent 2.2.0

#### xtevent
```stata
Expand All @@ -94,70 +102,75 @@ webuse nlswork, clear
by idcode (year): gen time=_n
xtset idcode time
*Generate a policy variable that follows staggered-adoption
*Generate a policy variable that follows staggered adoption
by idcode (time): gen union2=sum(union)
replace union2=1 if union2>1
order time union union2, after(year)
*** examples
*** Examples
*Estimate a basic event study with clustered standard errors
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode)
*Omit fixed effects
pol(union) w(3) cluster(idcode) impute(nuchange)
*Omit unit and time fixed effects
*Impute the policy variable verifying staggered adoption
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union2) w(3) cluster(idcode) nofe note impute(stag)
*Adjust the pre-trend by estimating a linear trend by GMM
* Bring back unit and time fixed effects
*Adjust for a pre-trend by estimating a linear trend by GMM
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode) trend(-2, method(gmm))
pol(union2) w(3) cluster(idcode) trend(-2, method(gmm)) ///
impute(stag)
*FHS estimator with proxy variables
*Freyaldenhoven, Hansen and Shapiro (2019) estimator with proxy variables
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) vce(cluster idcode) proxy(wks_work)
pol(union) w(3) vce(cluster idcode) proxy(wks_work) ///
impute(stag)
*reghdfe and two-way clustering
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) impute(nuchange) cluster(idcode year) reghdfe ///
proxy(wks_work)
pol(union2) w(3) impute(stag) cluster(idcode year) reghdfe ///
proxy(wks_work)
*Sun and Abraham Estimator
*generate the variable that indicates cohort
gen timet=year if union==1
*Sun and Abraham (2021) Estimator
*Generate the variable that indicates cohort
gen timet=year if union2==1
by idcode: egen time_of_treat=min(timet)
*generate the variable that indicates the control cohort.
*we use the never treated units as the control cohort.
*Generate the variable that indicates the control cohort
*We use the never-treated units as the control cohort
gen never_treat=time_of_treat==.
*estimate the event-time coefficients with the Sun-and-Abraham Estimator.
*estimate the event-time coefficients with the Sun-and-Abraham (2021) Estimator
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure, ///
policyvar(union) window(3) impute(nuchange) vce(cluster idcode) ///
policyvar(union2) window(3) impute(stag) vce(cluster idcode) ///
reghdfe cohort(time_of_treat) control_cohort(never_treat)
```

#### xteventplot
```stata
*** setup
*** Setup
webuse nlswork, clear
* year variable has many missing observations
* Create a time variable that ignores the gaps
by idcode (year): gen time=_n
xtset idcode time
*** examples
*Basic event study with clustered standard errors.
*Impute policy variable without verifying staggered adoption.
*** Examples
*Basic event study with clustered standard errors
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode) impute(nuchange)
* simple plot
* Simple plot
xteventplot
*Plot smoothest path in confidence region
xteventplot, smpath(line)
*FHS estimator with proxy variables
*Freyaldenhoven, Hansen and Shapiro (2019) estimator with proxy variables
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) vce(cluster idcode) impute(nuchange) ///
proxy(wks_work)
Expand All @@ -177,7 +190,7 @@ xtset idcode year
*** examples
*Basic event study with clustered standard errors.
*Impute policy variable without verifying staggered adoption.
*Impute the policy variable assuming no unobserved changes
xtevent ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure , ///
pol(union) w(3) cluster(idcode) impute(nuchange)
Expand Down
2 changes: 1 addition & 1 deletion xtevent/_eventiv.ado
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ program define _eventiv, rclass

if "`gen'" != "nogen" {
*If impute was specified, this is the second call to _eventgenvars: this time, both the policyvar and the event-time dummies will be imputed. Additional computations will happen as well (e.g., macros, etc.).
_eventgenvars if `touse', panelvar(`panelvar') timevar(`timevar') policyvar(`policyvar') lwindow(`lwindow') rwindow(`rwindow') `trend' norm(`norm') impute(`impute') `repeatedcs'
_eventgenvars if `tousegen', panelvar(`panelvar') timevar(`timevar') policyvar(`policyvar') lwindow(`lwindow') rwindow(`rwindow') `trend' norm(`norm') impute(`impute') `repeatedcs'
loc included=r(included)
loc names=r(names)
loc komittrend=r(komittrend)
Expand Down
2 changes: 1 addition & 1 deletion xtevent/get_unit_time_effects.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* get_unit_time_effects.ado 1.0.0 Nov 14 2022
*! get_unit_time_effects.ado 2.2.0 March 15 2023

version 11.2

Expand Down
55 changes: 38 additions & 17 deletions xtevent/get_unit_time_effects.sthlp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

{smcl}
{* *! version 1.0.0 Nov 14 2022}{...}
{* *! version 2.2.0 Mar 15 2023}{...}
{cmd:help get_unit_time_effects}
{hline}

{title:Title}

{phang}
{bf:get_unit_time_effects} {hline 2} Generate Group & Time effects in a Repeated Cross-Sectional Dataset

{bf:get_unit_time_effects} {hline 2} Generate Group and Time Effects in a Repeated Cross-Sectional Dataset

{marker syntax}{...}
{title:Syntax}
Expand All @@ -28,7 +27,7 @@
{synopthdr}
{synoptline}
{syntab:Main}
{synopt: {opth p:anelvar(varname)}} variable that identifies the groups at which effects will be computed {p_end}
{synopt: {opth p:anelvar(varname)}} variable that identifies the groups{p_end}
{synopt: {opth t:imevar(varname)}} variable that identifies the time periods{p_end}
{synopt: {opt saving(filename, [replace])}} save results to {it:filename}{p_end}
{synopt:{opt noo:utput}} omit regression table{p_end}
Expand All @@ -45,24 +44,27 @@
{title:Description}

{pstd}
{cmd: get_unit_time_effects} estimates group-time fixed effects in a repeated cross-sectional dataset. It produces a Stata data file with the variables {it:panelvar}, {it:timevar}, and {it:_unittimeeffects}. The variable
{it:_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. {cmd:get_unit_time_effects} implements the first part of the two-step procedure. Then,
{cmd: xtevent} can be used for the second part of the procedure to obtain the event-study coefficient estimates. See {help xtevent}.{p_end}
{cmd: get_unit_time_effects} estimates group-time fixed effects in a repeated cross-sectional dataset. It produces a Stata data file with the
variables {it:panelvar}, {it:timevar}, and {it:_unittimeeffects}. The variable {it:_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. {cmd:get_unit_time_effects} implements the first part of the two-step procedure. Then, {cmd: xtevent} can
be used for the second part of the procedure to obtain the event-study coefficient estimates. See {help xtevent}.{p_end}

{marker options}{...}
{title:Options}
{synoptline}

{phang}
{opth panelvar(varname)} specifies the group variable. For the Hansen (2007), the policy variable should vary at this group level.
{opth panelvar(varname)} specifies the group variable. For the Hansen (2007) estimator, the policy variable should vary at this group level.

{phang}
{opth timevar(varname)} specifies the time variable.

{phang}
{opt saving(filename, [replace])} specifies the name of the Stata data file which contains the unit-time effects estimates. If {opt saving} is not specified, the file will be saved in the
current directory with the name {it: unit_time_effects.dta}. The suboption {it:replace} overwrites the unit-time effects file.
{opt saving(filename, [replace])} specifies the name of the Stata data file which contains the unit-time effects estimates. If {opt saving} is
not specified, the file will be saved in the current directory with the name {it: unit_time_effects.dta}. The suboption {it:replace} overwrites
the unit-time effects file.

{phang}
{opt nooutput} omits the regression table.
Expand All @@ -73,28 +75,47 @@ current directory with the name {it: unit_time_effects.dta}. The suboption {it:r
{title:Examples}

{hline}
{pstd}Load the small version of the repeated cross-sectional dataset example31{p_end}
{pstd}Load example repeated cross-sectional dataset{p_end}
{phang2}{cmd:. use "https://github.com/JMSLab/xtevent/blob/main/test/small_repeated_cross_sectional_example31.dta?raw=true", clear}{p_end}
{phang2}{cmd:. {stata xtset, clear}}{p_end}

{pstd}Get unit-time effects and save them as a dta file with the name and directory indicated through the {bf:saving} option. Add the {bf:replace} suboption to overwrite the file.{p_end}
{phang2}{cmd:. get_unit_time_effects y u eta, panelvar(state) timevar(t) saving("My_directory/effect_file.dta", replace)}
{pstd}Get unit-time effects and save them as a dta file with the name and directory indicated through the {bf:saving} option. Add the
{bf:replace} suboption to overwrite the file.{p_end}
{phang2}{cmd:. {stata get_unit_time_effects y u eta, panelvar(state) timevar(t) saving("effect_file.dta", replace)}}
{p_end}

{pstd}Proceed with {bf:xtevent}{p_end}
{phang2}{cmd:. {stata "bysort state t (z): keep if _n==1"}}{p_end}
{phang2}{cmd:. {stata "keep state t z"}}{p_end}

{pstd}Merge with the file that was created with {bf:get_unit_time_effects}{p_end}
{phang2}{cmd:. merge m:1 state t using "My_directory/effect_file.dta"}{p_end}
{phang2}{cmd:. {stata "merge m:1 state t using effect_file.dta"}}{p_end}
{phang2}{cmd:. {stata drop _merge}}{p_end}
{pstd}Use {bf:xtevent} to estimate an event-study{p_end}
{phang2}{cmd:. {stata xtevent effects, panelvar(state) t(t) policyvar(z) window(5)}}{p_end}
{phang2}{cmd:. {stata xtevent _unittimeeffects, panelvar(state) t(t) policyvar(z) window(5)}}{p_end}
{phang2}{cmd:. {stata xteventplot}}{p_end}

{title:Authors}

{pstd}Simon Freyaldenhoven, Federal Reserve Bank of Philadelphia.{p_end}
[email protected]
{pstd}Christian Hansen, University of Chicago, Booth School of Business.{p_end}
[email protected]
{pstd}Jorge Pérez Pérez, Banco de México.{p_end}
[email protected]
{pstd}Jesse Shapiro, Harvard University and NBER.{p_end}
[email protected]

{title:Support}

{pstd}For support and to report bugs please email Jorge Pérez Pérez, Banco de México.{break}
[email protected]

{pstd}{cmd:xtevent} can also be found on {browse "https://github.com/JMSLab/xtevent":GitHub}.

{title:References}

{pstd}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.
{pstd}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.{p_end}


16 changes: 9 additions & 7 deletions xtevent/release.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xtevent 2.1.1 - August 12, 2022
xtevent 2.2.2 - Mar 15, 2023


Authors:
Expand All @@ -7,9 +7,9 @@ Authors:
[email protected]
Christian Hansen, University of Chicago, Booth School of Business.
[email protected]
Jorge Pérez Pérez, Banco de México
Jorge Pérez Pérez, Banco de México.
[email protected]
Jesse Shapiro, Harvard University and NBER
Jesse Shapiro, Harvard University and NBER.
[email protected]


Expand All @@ -18,8 +18,10 @@ Simon Freyaldenhoven, Christian Hansen, Jorge Pérez Pérez, and Jesse M. Shapir


Changelog:
- Fixed bugs present in xtevent 2.1.0.
- Updates in the help files and other documentation.
- Add cohort and control_cohort to obtain estimates using Sun and Abraham's (2021) method.
- Add repeatedcsoption and get_unit_time_effectscommand to estimate event-studies in repeated cross-section settings.
- Add noestimate option to savek() to generate event-time dummies without estimating the regression model.
- Enable clustered and robust standard erros for IV estimation without reghdfe.
- Fixed bugs present in version 2.1.1.


For more information, see https://github.com/JMSLab/xtevent/releases/tag/v2.1.1.
For more information, see https://github.com/JMSLab/xtevent/releases/tag/v2.2.0.
2 changes: 1 addition & 1 deletion xtevent/xtevent.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* xtevent.ado 2.2.0 Sep 29 2022
*! xtevent.ado 2.2.0 Mar 15 2023

version 11.2

Expand Down
Loading

0 comments on commit 6051123

Please sign in to comment.