Announcement

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

  • Parallel trends assumption test for a two way fixed effect model

    Hi everyone,

    I'm trying to test for the parallel trend assumption in the difference in difference. I'm trying to estimate this two way fixed effect model.

    xtpcse lunemployment_rate uber i.uber##time_fe2-timefe97 CMA_fe2-CMA_fe34 time_fe2-time_fe97

    My panel data is monthly. Uber is a dummy variable that is equal to one whenever uber enters a Metropolitan area and zero if not. Uber didn't enter into some areas which make it zero for all months for this area. I have a metropolitan area fixed effects, time fixed effects. The time fixed effects are generated from month and year using this code: "gen month_year = ym(YEAR, MONTH)
    format month_year %tm" and then
    "tab month_year, gen(time_fe)"

    I'm trying to interact my uber dummy variable with the time fixed effects in order to have leads and lags that I can test with the parallel trends assumption. Please see below a sample of my data.I have 97 periods per metropolitan area. I only included two fixed effects variables down.

    I have two questions:
    1) How can I include only months fixed effects if my data is a panel? (It gave me an error message when I tried to do so, I resorted then to a year and month fixed effects combined)

    2) How do I generate the leads and lags interaction factor in order to test for the parallel trends assumption for the difference in difference?

    please let me know if you need any more information. I have been trying to generate this interaction factor for the past 3 days. Any help is appreciated.
    Thank you,
    Ahmad

    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float uber byte(time_fe2 time_fe3) float month_year byte MONTH int YEAR
    0 0 0 605 6 2010
    0 1 0 606 7 2010
    0 0 1 607 8 2010
    0 0 0 608 9 2010
    0 0 0 609 10 2010
    0 0 0 610 11 2010
    0 0 0 611 12 2010
    0 0 0 612 1 2011
    0 0 0 613 2 2011
    0 0 0 614 3 2011
    0 0 0 615 4 2011
    0 0 0 616 5 2011
    0 0 0 617 6 2011
    0 0 0 618 7 2011
    0 0 0 619 8 2011
    0 0 0 620 9 2011
    0 0 0 621 10 2011
    0 0 0 622 11 2011
    0 0 0 623 12 2011
    0 0 0 624 1 2012
    0 0 0 625 2 2012
    0 0 0 626 3 2012
    0 0 0 627 4 2012
    0 0 0 628 5 2012
    0 0 0 629 6 2012
    0 0 0 630 7 2012
    0 0 0 631 8 2012
    0 0 0 632 9 2012
    0 0 0 633 10 2012
    0 0 0 634 11 2012
    0 0 0 635 12 2012
    0 0 0 636 1 2013
    0 0 0 637 2 2013
    0 0 0 638 3 2013
    0 0 0 639 4 2013
    0 0 0 640 5 2013
    0 0 0 641 6 2013
    0 0 0 642 7 2013
    0 0 0 643 8 2013
    0 0 0 644 9 2013
    0 0 0 645 10 2013
    0 0 0 646 11 2013
    0 0 0 647 12 2013
    0 0 0 648 1 2014
    0 0 0 649 2 2014
    0 0 0 650 3 2014
    0 0 0 651 4 2014
    0 0 0 652 5 2014
    0 0 0 653 6 2014
    0 0 0 654 7 2014
    0 0 0 655 8 2014
    0 0 0 656 9 2014
    0 0 0 657 10 2014
    0 0 0 658 11 2014
    0 0 0 659 12 2014
    0 0 0 660 1 2015
    0 0 0 661 2 2015
    0 0 0 662 3 2015
    0 0 0 663 4 2015
    0 0 0 664 5 2015
    0 0 0 665 6 2015
    0 0 0 666 7 2015
    0 0 0 667 8 2015
    0 0 0 668 9 2015
    0 0 0 669 10 2015
    0 0 0 670 11 2015
    0 0 0 671 12 2015
    0 0 0 672 1 2016
    0 0 0 673 2 2016
    0 0 0 674 3 2016
    0 0 0 675 4 2016
    0 0 0 676 5 2016
    0 0 0 677 6 2016
    0 0 0 678 7 2016
    0 0 0 679 8 2016
    0 0 0 680 9 2016
    0 0 0 681 10 2016
    0 0 0 682 11 2016
    0 0 0 683 12 2016
    0 0 0 684 1 2017
    0 0 0 685 2 2017
    0 0 0 686 3 2017
    0 0 0 687 4 2017
    0 0 0 688 5 2017
    0 0 0 689 6 2017
    0 0 0 690 7 2017
    0 0 0 691 8 2017
    0 0 0 692 9 2017
    0 0 0 693 10 2017
    0 0 0 694 11 2017
    0 0 0 695 12 2017
    0 0 0 696 1 2018
    0 0 0 697 2 2018
    0 0 0 698 3 2018
    0 0 0 699 4 2018
    0 0 0 700 5 2018
    0 0 0 701 6 2018
    0 0 0 605 6 2010
    0 1 0 606 7 2010
    0 0 1 607 8 2010
    end
    format %tm month_year
    [/CODE]
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 3298 observations





  • #2
    First, aside for your questions, there is no need to create these time_fe variables. You are already using factor variable notation: you need to use it more effectively. Forget the time_fe variables. Instead:

    Code:
    xtpcse lunemployment_rate i.uber##i.month_year CMA_fe2-CMA_fe34
    I suspect that similar considerations apply to CMA_fe*. Were these created by something like -tab CME, gen(CMA_fe)-? If so, the code simplifies further to:
    Code:
    xtpcse lunemployment_rate i.uber##i.month_year i.CMA
    Finally, you do not say what you did to -xtset- your data. But from your description, it seems that the natural approach would be -xtset CMA month_year-. If that is the case, then you don't need to mention CMA explicitly because the -xtpcse- command will automatically include it. So your code finally simplifies to:
    Code:
    xtpcse lunemployment_rate i.uber##i.month_year
    1) How can I include only months fixed effects if my data is a panel? (It gave me an error message when I tried to do so, I resorted then to a year and month fixed effects combined)
    You already have a variable named month. So all you need to do is:

    Code:
    xtpcse lunemployment_rate i.uber##i.month_year i.month
    However, month is going to be colinear with the month_year variables, so this will not provide any new information and will only make your model results confusing. Whatever information the month effects might provide is already carried in the month_year variables and its effects cannot be separately estimated.

    Do you mean that you want the fixed effects to be month only, and eliminate the month-year effects? If so
    Code:
    xtpcs lunemployment_rate i.uber##i.month
    will do that. I have a hard time making any sense of this kind of model--but this is not my area of expertise so perhaps you understand something about this subject matter that I am missing. I do have to say, however, that it sounds like adding month fixed effects to this model is either impossible or a bad idea.

    2) How do I generate the leads and lags interaction factor in order to test for the parallel trends assumption for the difference in difference?
    I'm not sure exactly what you have in mind. But, for example, if you want to have an interaction between the first two lags of uber and the month_year variable, you would code that as:
    Code:
    xtpcs lunemployment_rate L(1/2).uber##i.month_year
    From your questions, I get the sense that it would be worth your while to review -help tsvarlist- and -help fvvarlist-, and the PDF manual sections linked to in those windows to brush up your understanding of time-series operators and factor-variable notation.

    By the way, thank you for using -dataex- on your very first post.

    Comment

    Working...
    X