Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Event study - Dropping observations within a leads-lags framework

    Hi Statalist users,

    I am conducting an event study where the outcome variable is the total number of sick spells for region i in the year-month t (variable modate). In total I have 84 year-month observations for each of the 50 regions forming a balanced panel. The key explanatory variable is x. To conduct the event study, I have created eight leads and lags (as dummy 1-0 variables) and the "event" dummy. The problem is that I need to run the regression only within the lag 8 - lead 8 period, in other words drop everything after lead 8 and lag 8 (so that I can choose the event variable as the reference one), and I do not know how to do this.
    I am using STATA version 15.

    This is the code I have so far:

    Code:
    xtset region modate
    xtreg spells event L(1/8).event F(1/8).event i.month i.year, fe cluster(region)
    This code gives me the estimates for all the observations, not only those within the ag 8 - lead 8 period.

    I was thinking about collapsing the data so I can have only the estimation window I want, but I am not sure about writting the collapse command in this case.


    A preview of my data: (I only show here some of the leads and lags adn only 2 of the 50 regions)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte region float(year month) double spells float(modate event pre1 pre2 post1 post2)
    1 2009  1  6982 588 1 . . 0 0
    1 2009  2  5203 589 0 1 . 0 1
    1 2009  3  5371 590 0 0 1 1 0
    1 2009  4  3749 591 1 0 0 0 0
    1 2009  5  4820 592 0 1 0 0 0
    1 2009  6  4713 593 0 0 1 0 0
    1 2009  7  3996 594 0 0 0 0 1
    1 2009  8  2762 595 0 0 0 1 0
    1 2009  9  5386 596 1 0 0 0 0
    1 2009 10  7058 597 0 1 0 0 0
    1 2009 11  8191 598 0 0 1 0 1
    1 2009 12  4912 599 0 0 0 1 0
    1 2010  1  5806 600 1 0 0 0 0
    1 2010  2  5709 601 0 1 0 0 0
    1 2010  3  5428 602 0 0 1 0 1
    1 2010  4  4079 603 0 0 0 1 0
    1 2010  5  5039 604 1 0 0 0 0
    1 2010  6  4641 605 0 1 0 0 0
    1 2010  7  3838 606 0 0 1 0 0
    1 2010  8  2484 607 0 0 0 0 0
    1 2010  9  4520 608 0 0 0 0 0
    1 2010 10  4807 609 0 0 0 0 0
    1 2010 11  5627 610 0 0 0 0 1
    1 2010 12  5112 611 0 0 0 1 0
    1 2011  1  7783 612 1 0 0 0 0
    1 2011  2  5444 613 0 1 0 0 0
    1 2011  3  6099 614 0 0 1 0 0
    1 2011  4  3637 615 0 0 0 0 0
    1 2011  5  5158 616 0 0 0 0 1
    1 2011  6  4517 617 0 0 0 1 0
    1 2011  7  3449 618 1 0 0 0 1
    1 2011  8  2382 619 0 1 0 1 0
    1 2011  9  4251 620 1 0 1 0 1
    1 2011 10  4693 621 0 1 0 1 1
    1 2011 11  5379 622 1 0 1 1 1
    1 2011 12  3786 623 1 1 0 1 1
    1 2012  1  5626 624 1 1 1 1 0
    1 2012  2  5809 625 1 1 1 0 0
    1 2012  3  4380 626 0 1 1 0 0
    1 2012  4  3013 627 0 0 1 0 0
    1 2012  5  3830 628 0 0 0 0 0
    1 2012  6  3280 629 0 0 0 0 0
    1 2012  7  2620 630 0 0 0 0 0
    1 2012  8  1610 631 0 0 0 0 0
    1 2012  9  3034 632 0 0 0 0 0
    1 2012 10  3962 633 0 0 0 0 0
    1 2012 11  3685 634 0 0 0 0 0
    1 2012 12  2690 635 0 0 0 0 0
    1 2013  1  4623 636 0 0 0 0 0
    1 2013  2  5022 637 0 0 0 0 0
    1 2013  3  3936 638 0 0 0 0 0
    1 2013  4  3380 639 0 0 0 0 0
    1 2013  5  3589 640 0 0 0 0 0
    1 2013  6  2907 641 0 0 0 0 0
    1 2013  7  2553 642 0 0 0 0 0
    1 2013  8  1547 643 0 0 0 0 0
    1 2013  9  3139 644 0 0 0 0 0
    1 2013 10  3778 645 0 0 0 0 0
    1 2013 11  3715 646 0 0 0 0 0
    1 2013 12  3119 647 0 0 0 0 0
    1 2014  1  5436 648 0 0 0 0 0
    1 2014  2  4295 649 0 0 0 0 1
    1 2014  3  4090 650 0 0 0 1 0
    1 2014  4  2664 651 1 0 0 0 0
    1 2014  5  3461 652 0 1 0 0 0
    1 2014  6  3355 653 0 0 1 0 0
    1 2014  7  2566 654 0 0 0 0 0
    1 2014  8  1624 655 0 0 0 0 0
    1 2014  9  3526 656 0 0 0 0 0
    1 2014 10  4526 657 0 0 0 0 0
    1 2014 11  3787 658 0 0 0 0 0
    1 2014 12  3013 659 0 0 0 0 1
    1 2015  1 11022 660 0 0 0 1 1
    1 2015  2 11502 661 1 0 0 1 0
    1 2015  3  8682 662 1 1 0 0 0
    1 2015  4  5738 663 0 1 1 0 1
    1 2015  5  6910 664 0 0 1 1 0
    1 2015  6  6786 665 1 0 0 0 0
    1 2015  7  5014 666 0 1 0 0 0
    1 2015  8  3422 667 0 0 1 0 0
    1 2015  9  6184 668 0 0 0 0 0
    1 2015 10  7328 669 0 0 0 0 0
    1 2015 11  7672 670 0 0 0 0 .
    1 2015 12  5862 671 0 0 0 . .
    2 2009  1  2989 588 0 . . 1 1
    2 2009  2  2586 589 1 0 . 1 0
    2 2009  3  2595 590 1 1 0 0 1
    2 2009  4  2247 591 0 1 1 1 1
    2 2009  5  2553 592 1 0 1 1 0
    2 2009  6  2338 593 1 1 0 0 0
    2 2009  7  2178 594 0 1 1 0 0
    2 2009  8  1970 595 0 0 1 0 1
    2 2009  9  2553 596 0 0 0 1 0
    2 2009 10  2935 597 1 0 0 0 0
    2 2009 11  3323 598 0 1 0 0 1
    2 2009 12  2349 599 0 0 1 1 0
    2 2010  1  2433 600 1 0 0 0 1
    2 2010  2  2532 601 0 1 0 1 0
    2 2010  3  2501 602 1 0 1 0 0
    2 2010  4  2282 603 0 1 0 0 0
    end
    format %tm modate
    Any help will be highly appreciated.

    Thank you.
    Last edited by Grace Armijos; 28 Nov 2019, 08:38.
Working...
X