Announcement

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

  • Panel regression -firm year quarter fixed effects

    Dear all,
    I attached an example of the sample which is a panel dataset. I have two firms X, and Y, observations are by year and quarter (fqtr 1,2,3,4). ID is the unique firm identifier.

    Question :
    In areg model, I control for ID (firm id) year, quarter fixed effect, I first generate the following variable

    egen yr_qtr=group(fyearq fqtr )

    then

    areg yvar x1 x2 x3 $yrqtr, absorb(ID)



    Is this the right way for fixed effect I described above?


    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int ID str1 Company int(datadate fyearq) byte fqtr double(x1 x2 x3 yvar) str5 Relation
    4839 "X" 21639 2019 1 8.78 .006202498450875282 .2533224821090698 .4352763891220093 "T2"
    4839 "X" 21274 2018 1 11.08 .006657186895608902 .24117426574230194 .649627685546875 "T3"
    4839 "X" 21274 2018 1 11.08 .006657186895608902 .24117426574230194 .649627685546875 "T1-T3"
    4839 "X" 21365 2018 2 11.07 .014290197752416134 .2516477406024933 .4130518138408661 "T3"
    4839 "X" 21365 2018 2 11.07 .014290197752416134 .2516477406024933 .4130518138408661 "T1-T3"
    4839 "X" 21365 2018 2 11.07 .014290197752416134 .2516477406024933 .4130518138408661 "T1"
    4839 "X" 21365 2018 2 11.07 .014290197752416134 .2516477406024933 .4130518138408661 "T2"
    4839 "X" 21457 2018 3 9.25 .021890904754400253 .252164363861084 .3826757073402405 "T1-T3"
    4839 "X" 21457 2018 3 9.25 .021890904754400253 .252164363861084 .3826757073402405 "T1"
    4839 "X" 21549 2018 4 7.65 .03034614399075508 .25452950596809387 -.0452171191573143 "T2"
    4839 "X" 21549 2018 4 7.65 .03034614399075508 .25452950596809387 -.0452171191573143 "T3"
    4839 "X" 21639 2019 1 8.78 .006202498450875282 .2533224821090698 .4352763891220093 "T1-T3"
    4839 "X" 21639 2019 1 8.78 .006202498450875282 .2533224821090698 .4352763891220093 "T1"
    4839 "X" 21730 2019 2 10.23 .013551551848649979 .2581316828727722 .056448906660079956 "T1"
    4839 "X" 21730 2019 2 10.23 .013551551848649979 .2581316828727722 .056448906660079956 "T2"
    4839 "X" 21730 2019 2 10.23 .013551551848649979 .2581316828727722 .056448906660079956 "T3"
    5073 "Y" 21549 2018 4 7.65 .03034614399075508 .25452950596809387 -.0452171191573143 "T1-T3"
    5073 "Y" 21274 2018 1 11.08 .006657186895608902 .24117426574230194 .649627685546875 "T2"
    5073 "Y" 21274 2018 1 11.08 .006657186895608902 .24117426574230194 .649627685546875 "T1"
    5073 "Y" 21457 2018 3 9.25 .021890904754400253 .252164363861084 .3826757073402405 "T2"
    5073 "Y" 21457 2018 3 9.25 .021890904754400253 .252164363861084 .3826757073402405 "T3"
    5073 "Y" 21549 2018 4 7.65 .03034614399075508 .25452950596809387 -.0452171191573143 "T1"
    5073 "Y" 21639 2019 1 8.78 .006202498450875282 .2533224821090698 .4352763891220093 "T3"
    5073 "Y" 21730 2019 2 10.23 .013551551848649979 .2581316828727722 .056448906660079956 "T1-T3"


    By the way, I have not posted for a long while, and forgot about how to disply data in a box.

    Thanks in advance

    Rochelle

  • #2
    Dear Rochelle,

    I am assuming that you are receiving some sort of error when you tried to run this code yourself. There are some syntactical/grammatical errors. Specifically, it appears that you misspelled the year-quarter variable. Unless I am mistaken, it should be yr_qtr. In order to include this variable as a dummy to act as fixed effects, you should include it in the regression as i.yr_qtr

    Hope this helps

    Comment


    • #3
      Dear Salvatore,
      Thank you for catching my typo. It should be yr_qtr.

      is there a difference between using i.year i.quarter

      vs.

      egen yr_qtr=group(fyearq fqtr )

      then

      i.yr_qtr

      in the regression.

      In other words, grouping year and quarter into one variable is the same as using two " i." function , right?


      Comment

      Working...
      X