Announcement

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

  • Panel Data Time Fixed Effect

    Hello Statalist,

    I am sitting on my dataset and try to do some regressions with fixed effects.

    I want to hold Fixed Effects for companies/names and by month. For companies/names I created a new variable and grouped them:
    Code:
    egen xname = group(company)
    After that I set the panel regression
    Code:
    xtset xname monthly_date, monthly
    xtreg ri mktminusrf smb_5 hml rmw cma logfund, fe
    The get the regression for company fixed effect.

    Now I want to fix my monthly data. So I generated a new variable and grouped them:
    Code:
    egen timex = group(monthly_date)
    After that I wanted to do the same steps like above but I get the error:
    Code:
    . xtset timex monthly_date, monthly
    repeated time values within panel
    r(451);
    My final goal is a regression with company and month fixed effect.

    My dataset looks like this
    Code:
     * Example generated by -dataex-. To install: ssc install dataex clear input double logfund float(date monthly_date) double(mktminusrf smb_5 hml rmw cma rf) byte company str8 Name double(ri exreturn) float(namex timex) -2.428878818318338 18321 601   3.4  1.53  2.74  -.55  1.43   0 3 "BAC"   9.74967061923584   1.0792420903186335 1  1  4.750675543873377 18352 602  6.31  1.85  2.01   -.9  1.67 .01 3 "BAC"   7.19288115246098    7.863939303648687 1  2 -1.547824874555269 18382 603     2  5.03  3.12   .49  1.69 .01 3 "BAC" -.1219820828667389    7.512007394694056 1  3 -2.377775945715615 18413 604 -7.89  -.08 -2.32  1.38  -.18 .01 3 "BAC" -11.73197309417041   -7.985979824222701 1  4  2.033946504409595 18443 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 3 "BAC" -8.650023366859694  -6.3356267642576265 1  5  1.866966321771243 18474 606  6.93   .13   .04   .32  2.03 .01 3 "BAC"  -2.30703713485449   2.8818557462931853 1  6 -6.230064946559605 18505 607 -4.77 -3.07 -1.51   .34 -2.13 .01 3 "BAC" -11.26298770771683    -9.47372995462771 1  7  5.650530448089943 18535 608  9.54  3.71 -2.94  -.01   .39 .01 3 "BAC"  5.226579911347658    6.938139934459892 1  8   .453532778924937 18566 609  3.88   .72 -2.23  1.46  -.16 .01 3 "BAC" -12.63015385787189  -1.0581368275386804 1  9 -2.051943886966359 18596 610    .6  3.54  -.58   -.1  1.76 .01 3 "BAC" -4.368399944212481   -.2466604777739864 1 10  2.453635974122106 18627 611  6.82  1.03  3.47 -3.44  3.44 .01 3 "BAC"  21.90832010280622   14.130063735152843 1 11 -2.555251514231911 18658 612  1.99 -2.38   .68 -1.07    .8 .01 3 "BAC"  2.913674964491289   -.7969297791341909 1 12 -.3940574407002404 18686 613  3.49  1.76  1.73 -1.76   .72 .01 3 "BAC"  4.068267880099642    .5468279827189714 1 13  .9019179029163964 18717 614   .45  2.66 -1.16  1.21  -.03 .01 3 "BAC" -6.657778025904411    .9523648032545909 1 14 -3.366182863817053 18747 615   2.9  -.41 -2.15   .96 -1.28   0 3 "BAC" -7.876952978993803    .5892439640544306 1 15  3.801343710610448 18778 616 -1.27  -.69 -2.12  2.02 -1.46   0 3 "BAC" -4.316214001119832  -1.4900158368765897 1 16  .5375060083539553 18808 617 -1.75   .09  -.26  2.16  -1.4   0 3 "BAC"  -6.63788863069695  -2.2422322337233376 1 17 -.9872492784416207 18839 618 -2.36 -1.38 -1.18  2.41 -1.75   0 3 "BAC" -11.40552472135674   -3.803201280158997 1 18  .6191782687064706 18870 619 -5.99 -3.39 -1.58  2.79  -.23 .01 3 "BAC" -15.76704135095508  -10.010273678945138 1 19   .263701731990106 18900 620 -7.59  -3.9  -.98  1.71   .24   0 3 "BAC" -25.09158623711403   -9.691976652945483 1 20 -1.255992779152897 18931 621 11.35  3.72  -.96 -1.42  -.86   0 3 "BAC"  11.60089037646026   14.101807651955239 1 21 -7.328765598425764 18961 622  -.28  -.34  -.18  1.46  1.52   0 3 "BAC" -20.20469666749166   -.7010521563359488 1 22  6.918695219020471 18992 623   .74  -.36  1.57   .59  2.44   0 3 "BAC"  2.205842106223427    2.806981029536361 1 23  1.664472961319299 19023 624  5.05  2.35 -2.14 -1.05 -1.41   0 3 "BAC"  28.23735227962441   4.8123002274651165 1 24 -4.488823618117669 19052 625  4.42 -1.54   .01  -.17  -.03   0 3 "BAC"   11.9215991981736    4.929256079524911 1 25  2.808398174936492 19083 626  3.11   -.3  -.06   .25   .77   0 3 "BAC"  20.07462686567165    6.134441796438538 1 26 -.1262357447864098 19113 627  -.85  -.66   -.2   .96   .72   0 3 "BAC" -15.25585249637455   -.6589440873023982 1 27  .4387329863579144 19144 628 -6.19   -.2   .08  1.98  2.37 .01 3 "BAC" -9.258032073534451   -5.232003502156304 1 28  .6944331180936318 19174 629  3.89   .99   .54 -1.48   .37   0 3 "BAC"  11.29353769900062   3.1610056320207667 1 29 -.8876966737515692 19205 630   .79 -2.74   .01   .68   .12   0 3 "BAC" -10.26975348234923  -2.1943797153019506 1 30  1.840011420252095 19236 631  2.55   .61    .6  -.77  -.69 .01 3 "BAC"  8.845620743138433   3.2097822852500713 1 31 -.6554042290035031 19266 632  2.73   .69  1.56 -1.14  1.57 .01 3 "BAC"  10.62919416188624   3.7440350444895922 1 32 -.2497564922306408 19297 633 -1.76   -.8  4.16 -1.35  2.28 .01 3 "BAC"  5.538836480100336 -.011272835365493195 1 33 -2.997485122381406 19327 634   .78   .41 -1.12   .94   .93 .01 3 "BAC"  5.783980032465801  -1.7071354681310214 1 34  2.968343045907073 19358 635  1.18  1.91  3.26 -1.75   .88 .01 3 "BAC"  17.84005114627837   3.0426481552350655 1 35  .2701289866054237 19389 636  5.57   .57  1.34 -1.88  1.47   0 3 "BAC" -2.497596010654139     4.35358834602998 1 36  .1509605075700726 19417 637  1.29  -.35   .28  -.96   .49   0 3 "BAC" -.7069419958456361    1.795811335142118 1 37 -1.062582825088892 19448 638  4.03    .9  -.07   .13  1.21   0 3 "BAC"  8.459320722874628    4.731694854308733 1 38  2.455217987516834 19478 639  1.56 -2.32   .35   .04   .39   0 3 "BAC"  1.067330134854775  -1.2287103279354548 1 39 -.6101666516017357 19509 640   2.8  2.27  1.33  -.71  -.83   0 3 "BAC"  10.96632961534452    4.940060638818192 1 40 -.8187397318572058 19539 641  -1.2  1.33   -.4  -.47   .01   0 3 "BAC"  -5.78314123640568   2.5241690106418964 1 41  .1706158923222114 19570 642  5.65  1.81   .71 -1.43   .53   0 3 "BAC"  13.53024190455739    7.810874448103845 1 42 -.7756070164821449 19601 643 -2.71  -.03 -2.48   .85 -2.13   0 3 "BAC" -3.287326969457456  -3.4978214824446687 1 43  1.726891305749435 19631 644  3.77  2.72 -1.57   -.1 -1.32   0 3 "BAC"  -2.19549166299936    1.662269053409685 1 44  .3957065823815764 19662 645  4.18 -1.57  1.36  2.83   .89   0 3 "BAC"  1.232019655177335    3.530331927754367 1 45 -1.548639224836185 19692 646  3.12  1.47  -.38   .77   .12   0 3 "BAC"  13.24265022329774    5.958017535781951 1 46 -1.181443691265908 19723 647  2.81  -.44   -.2  -.57   .07   0 3 "BAC" -1.517048888224331   1.7581796005450971 1 47 -.0883624242566112 19754 648 -3.32   .56 -1.88  -4.5 -1.42   0 3 "BAC"  7.578728949732418  -3.5093873014626227 1 48  1.654120853093416 19782 649  4.65   .16  -.49  -.49   -.4   0 3 "BAC" -1.313700354005207   2.4975777263943297 1 49  .7675383150229624 19813 650   .43 -1.23   4.6  1.76  1.91   0 3 "BAC"  4.113931593373855    4.418488481502362 1 50  .7337002959205572 19843 651  -.19 -4.21  1.62  2.85  1.09   0 3 "BAC" -11.97717543096541  -5.1449314506274195 1 51 -1.300090055657543 19874 652  2.06 -1.83  -.38   .45 -1.09   0 3 "BAC"                  0  -.15249468832704713 1 52  3.226876440418037 19904 653  2.61  3.04   -.6  -1.9  -1.9   0 3 "BAC"  1.585206473468275    5.056250663074427 1 53 -1.639863325627885 19935 654 -2.04 -4.16   .04  1.48   .44   0 3 "BAC" -.7802349025506456   -3.606526297369947 1 54 -1.073779734353744 19966 655  4.23    .3  -.76  -.91  -.65   0 3 "BAC"   5.50781854776281   2.3346652596238338 1 55 -.7707598557843998 19996 656 -1.97  -3.8 -1.68  1.28  -.62   0 3 "BAC"  6.277437421279833   -2.045957417917509 1 56  .1447530739194685 20027 657  2.52  3.79 -1.81  -.78  -.18   0 3 "BAC"  .6449163219633881    3.921821214508063 1 57  .1178356353986567 20057 658  2.55 -2.27 -3.37  1.69   .15   0 3 "BAC" -.6990888408729704    .2556962153253986 1 58  2.635474229565091 20088 659  -.06  2.85  1.56 -1.52   .81   0 3 "BAC"  5.281517853545095   1.6999100547668136 1 59 -3.078890081227631 20119 660 -3.11  -.91 -3.06  1.09 -1.67   0 3 "BAC" -15.31597537371373   -9.063475876310163 1 60  .4817352432663817 20147 661  6.13   .35 -2.16   .06 -1.62   0 3 "BAC"   4.35686522643044    7.821358748819076 1 61  .2211978151041967 20178 662 -1.12  3.07  -.73   .16  -.54   0 3 "BAC" -2.340530842046646    1.178161237891585 1 62  1.991202305673274 20208 663   .59 -2.99  2.13   .41  -.49   0 3 "BAC"  3.509094249494756   1.1699231204987903 1 63 -1.329517653461937 20239 664  1.36   .85  -1.9 -1.54  -.68   0 3 "BAC"  3.578029941365856   2.2829594903968538 1 64    .01391606423699 20269 665 -1.53  2.88 -1.04  1.03 -1.51   0 3 "BAC"  3.454429422331463    4.042932941219419 1 65  .3699056815049282 20300 666  1.54  -4.5 -4.49   .31  -2.6   0 3 "BAC"  5.053176298564061   -.4668957188768061 1 66 -.1181539396678257 20331 667 -6.04   .38  2.88   .75  1.14   0 3 "BAC" -8.613293462008967   -5.438906417704657 1 67  .1582819462867526 20361 668 -3.07 -2.81   .73  1.66   -.5   0 3 "BAC" -4.344877233271656  -1.0338013819885195 1 68  1.965128759761292 20392 669  7.75 -2.05  -.32  1.19   .45   0 3 "BAC"  7.701828585644973    4.103701862358857 1 69 -2.397516434496359 20422 670   .56  3.35 -1.23 -2.11    -1   0 3 "BAC"  3.873806760104661    4.884271693531826 1 70 -2.359402434240175 20453 671 -2.17    -3 -2.07   .45   .17 .01 3 "BAC" -3.165594842970808   -5.998214832502895 1 71  1.646352401779502 20484 672 -5.77 -3.56  3.13  2.27     3 .01 3 "BAC" -15.99323717672722    -9.57095304671795 1 72 -.8583285517720807 20513 673  -.07   .87  -.03  2.44  2.09 .02 3 "BAC" -11.47723012169207  -3.2244776400413957 1 73  1.201286271998179 20544 674  6.96  1.01   1.3   .58   .07 .02 3 "BAC"  8.366773160473809     7.35841145497473 1 74 -2.428878818318338 18321 601   3.4  1.53  2.74  -.55  1.43   0 5 "BBT"  2.368137782561895   1.0792420903186335 2  1  4.750675543873377 18352 602  6.31  1.85  2.01   -.9  1.67 .01 5 "BBT"  13.51961794602173    7.863939303648687 2  2 -1.547824874555269 18382 603     2  5.03  3.12   .49  1.69 .01 5 "BBT"  3.077372645878357    7.512007394694056 2  3 -2.377775945715615 18413 604 -7.89  -.08 -2.32  1.38  -.18 .01 5 "BBT" -9.035157232704403   -7.985979824222701 2  4  2.033946504409595 18443 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 5 "BBT" -13.00623063881619  -6.3356267642576265 2  5  1.866966321771243 18474 606  6.93   .13   .04   .32  2.03 .01 5 "BBT" -5.065110542705463   2.8818557462931853 2  6 -6.230064946559605 18505 607 -4.77 -3.07 -1.51   .34 -2.13 .01 5 "BBT" -10.92393114332057    -9.47372995462771 2  7  5.650530448089943 18535 608  9.54  3.71 -2.94  -.01   .39 .01 5 "BBT"  8.850566965344177    6.938139934459892 2  8   .453532778924937 18566 609  3.88   .72 -2.23  1.46  -.16 .01 5 "BBT" -2.169458881930408  -1.0581368275386804 2  9 -2.051943886966359 18596 610    .6  3.54  -.58   -.1  1.76 .01 5 "BBT" -.9071284330072684   -.2466604777739864 2 10  2.453635974122106 18627 611  6.82  1.03  3.47 -3.44  3.44 .01 5 "BBT"  13.30895218196535   14.130063735152843 2 11 -2.555251514231911 18658 612  1.99 -2.38   .68 -1.07    .8 .01 5 "BBT"   5.69565179666697   -.7969297791341909 2 12 -.3940574407002404 18686 613  3.49  1.76  1.73 -1.76   .72 .01 5 "BBT" -.1547070478347035    .5468279827189714 2 13  .9019179029163964 18717 614   .45  2.66 -1.16  1.21  -.03 .01 5 "BBT" -.5535264021315793    .9523648032545909 2 14 -3.366182863817053 18747 615   2.9  -.41 -2.15   .96 -1.28   0 5 "BBT" -1.311378461472698    .5892439640544306 2 15  3.801343710610448 18778 616 -1.27  -.69 -2.12  2.02 -1.46   0 5 "BBT"  2.303116065498028  -1.4900158368765897 2 16  .5375060083539553 18808 617 -1.75   .09  -.26  2.16  -1.4   0 5 "BBT" -2.541673135824082  -2.2422322337233376 2 17 -.9872492784416207 18839 618 -2.36 -1.38 -1.18  2.41 -1.75   0 5 "BBT" -3.726017676045373   -3.803201280158997 2 18  .6191782687064706 18870 619 -5.99 -3.39 -1.58  2.79  -.23 .01 5 "BBT" -13.21072808779173  -10.010273678945138 2 19   .263701731990106 18900 620 -7.59  -3.9  -.98  1.71   .24   0 5 "BBT" -4.307173712418937   -9.691976652945483 2 20 -1.255992779152897 18931 621 11.35  3.72  -.96 -1.42  -.86   0 5 "BBT"  10.17386579733768   14.101807651955239 2 21 -7.328765598425764 18961 622  -.28  -.34  -.18  1.46  1.52   0 5 "BBT" -.7286401183577812   -.7010521563359488 2 22  6.918695219020471 18992 623   .74  -.36  1.57   .59  2.44   0 5 "BBT"   8.63191710445154    2.806981029536361 2 23  1.664472961319299 19023 624  5.05  2.35 -2.14 -1.05 -1.41   0 5 "BBT"  8.660940215237343   4.8123002274651165 2 24 -4.488823618117669 19052 625  4.42 -1.54   .01  -.17  -.03   0 5 "BBT"  7.576411173654582    4.929256079524911 2 25  2.808398174936492 19083 626  3.11   -.3  -.06   .25   .77   0 5 "BBT"  7.316341633576536    6.134441796438538 2 26 end format %td date format %tm monthly_date
    thanks
    Last edited by Marius Bauer; 10 Dec 2020, 10:39.

  • #2
    If company is one variable and monthly_date is one variable, you don't need all those egens.
    Just
    Code:
    xtset company monthly_date
    Example:
    Code:
    . webuse grunfeld
    
    . xtset company year
           panel variable:  company (strongly balanced)
            time variable:  year, 1935 to 1954
                    delta:  1 year
    
    .

    Comment


    • #3
      Thank you for the example. I played a bit around. Just for my iunderstanding:

      In my case I would do the following if I just want to hold for company fixed effects
      Code:
      xtset company monthly_date
      xtreg ri x1 x2 x3 month, fe
      and if I want to hold for company and month fixed effect I would do the following:
      Code:
      xtset company monthly_date
      xtreg ri x1 x2 x3 i.month, fe
      am I right or do I miss understand something?

      Comment


      • #4
        In your case you can have two kinds of unobserved omitted variables: company specific and time speciific. With the FE option you take into account the company specific omitted variables. If you wish to take into account time specific omitted variables, you do that with i.month. But pleas decide whether your time variable is month or monthly_date.

        Comment


        • #5
          thanks again for the help.

          My month variable is only from 1 to 12 while my monthly_date is from 2010m2 to 2016m3. in order to hold for month fixed effect should I do
          Code:
          i.month
          or i.monthly_date
          Or does this not matter since my panel data is set monthly?

          Comment


          • #6
            Please read up a bit about panel data and panel data models. I don't even know why you created the month variable.
            Please produce the results of :
            Code:
            summarize company month monthly_date
            And you have not correctly used the dataex command because all your data is in one line wheareas it should be in table form. As it is it is unreadable.
            If you don't know how to use the dataex command, just produce the output from
            Code:
            list company month monthly_date in 1/20

            Comment


            • #7
              Thank you for the help. I am currently reading the MPRA Paper von Munich which is quite good. I guess I am overthinking the regression and only monthly_date is needed. I am also sorry about the dataex I am not sure why this did not work. I usually had no problems with that.

              Here is the summarize:
              Code:
              Variable |        Obs        Mean    Std. Dev.       Min        Max
              -------------+---------------------------------------------------------
                   company |      3,552        24.5    13.85535          1         48
                     month |      3,552    6.391892    3.467778          1         12
              monthly_date |      3,552       637.5    21.36302        601        674
              The sample Dataset

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input double logdiff_fintech_funding float monthly_date double(mktminusrf smb_5 hml rmw cma rf) byte company double ri float month
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0  3   9.74967061923584  2
               4.750675543873377 602  6.31  1.85  2.01   -.9  1.67 .01 44  4.505135967162661  3
              -1.547824874555269 603     2  5.03  3.12   .49  1.69 .01 37  .1944029612120065  4
              -2.377775945715615 604 -7.89  -.08 -2.32  1.38  -.18 .01 17                  .  5
               2.033946504409595 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 36  -9.11838855254167  6
               1.866966321771243 606  6.93   .13   .04   .32  2.03 .01 41 -21.52898734177215  7
              -6.230064946559605 607 -4.77 -3.07 -1.51   .34 -2.13 .01 36  -8.60099014231403  8
               5.650530448089943 608  9.54  3.71 -2.94  -.01   .39 .01 40  12.57651475214694  9
                .453532778924937 609  3.88   .72 -2.23  1.46  -.16 .01 17                  . 10
              -2.051943886966359 610    .6  3.54  -.58   -.1  1.76 .01 29                  . 11
               2.453635974122106 611  6.82  1.03  3.47 -3.44  3.44 .01 28                  . 12
              -2.555251514231911 612  1.99 -2.38   .68 -1.07    .8 .01  7 -3.231050971706022  1
              -.3940574407002404 613  3.49  1.76  1.73 -1.76   .72 .01  9  3.436958116783861  2
               .9019179029163964 614   .45  2.66 -1.16  1.21  -.03 .01  9  4.390203676154903  3
              -3.366182863817053 615   2.9  -.41 -2.15   .96 -1.28   0 24  10.11537205398713  4
               3.801343710610448 616 -1.27  -.69 -2.12  2.02 -1.46   0 35 -1.027769648576872  5
               .5375060083539553 617 -1.75   .09  -.26  2.16  -1.4   0  4  7.097518288207641  6
              -.9872492784416207 618 -2.36 -1.38 -1.18  2.41 -1.75   0 48 -8.788228649268232  7
               .6191782687064706 619 -5.99 -3.39 -1.58  2.79  -.23 .01 30 -18.54826850690088  8
                .263701731990106 620 -7.59  -3.9  -.98  1.71   .24   0  2 -22.14350681319415  9
              -1.255992779152897 621 11.35  3.72  -.96 -1.42  -.86   0  1  14.10180765195524 10
              -7.328765598425764 622  -.28  -.34  -.18  1.46  1.52   0 47 -1.107532457646879 11
               6.918695219020471 623   .74  -.36  1.57   .59  2.44   0 12 -4.257941601009321 12
               1.664472961319299 624  5.05  2.35 -2.14 -1.05 -1.41   0  3  28.23735227962441  1
              -4.488823618117669 625  4.42 -1.54   .01  -.17  -.03   0 12   8.49587110161415  2
               2.808398174936492 626  3.11   -.3  -.06   .25   .77   0 13  9.329645265530978  3
              -.1262357447864098 627  -.85  -.66   -.2   .96   .72   0 36 -4.202501338877862  4
               .4387329863579144 628 -6.19   -.2   .08  1.98  2.37 .01 12 -19.75573504697191  5
               .6944331180936318 629  3.89   .99   .54 -1.48   .37   0 16  8.577279775313778  6
              -.8876966737515692 630   .79 -2.74   .01   .68   .12   0  1 -2.194379715301951  7
               1.840011420252095 631  2.55   .61    .6  -.77  -.69 .01 26  5.167679606682242  8
              -.6554042290035031 632  2.73   .69  1.56 -1.14  1.57 .01 21   9.49520124176243  9
              -.2497564922306408 633 -1.76   -.8  4.16 -1.35  2.28 .01 10  .5491252619347943 10
              -2.997485122381406 634   .78   .41 -1.12   .94   .93 .01 32 -3.275233984502273 11
               2.968343045907073 635  1.18  1.91  3.26 -1.75   .88 .01  5  3.327117967717728 12
               .2701289866054237 636  5.57   .57  1.34 -1.88  1.47   0 29   -.51739673865652  1
               .1509605075700726 637  1.29  -.35   .28  -.96   .49   0  3 -.7069419958456361  2
              -1.062582825088892 638  4.03    .9  -.07   .13  1.21   0 18 -2.164492494639017  3
               2.455217987516834 639  1.56 -2.32   .35   .04   .39   0 22  -1.17120914972781  4
              -.6101666516017357 640   2.8  2.27  1.33  -.71  -.83   0 18  .9114275702083112  5
              -.8187397318572058 641  -1.2  1.33   -.4  -.47   .01   0  1  2.524169010641897  6
               .1706158923222114 642  5.65  1.81   .71 -1.43   .53   0 36   9.19230888895802  7
              -.7756070164821449 643 -2.71  -.03 -2.48   .85 -2.13   0 11  9.330632867430612  8
               1.726891305749435 644  3.77  2.72 -1.57   -.1 -1.32   0 48 -1.966430425835606  9
               .3957065823815764 645  4.18 -1.57  1.36  2.83   .89   0  8  1.230068337129839 10
              -1.548639224836185 646  3.12  1.47  -.38   .77   .12   0 20  27.06072848785985 11
              -1.181443691265908 647  2.81  -.44   -.2  -.57   .07   0 42  3.595071870535575 12
              -.0883624242566112 648 -3.32   .56 -1.88  -4.5 -1.42   0  4  12.42259585469816  1
               1.654120853093416 649  4.65   .16  -.49  -.49   -.4   0 43  4.024988917530001  2
               .7675383150229624 650   .43 -1.23   4.6  1.76  1.91   0 17   3.88680113795004  3
               .7337002959205572 651  -.19 -4.21  1.62  2.85  1.09   0 16 -4.434503379832694  4
              -1.300090055657543 652  2.06 -1.83  -.38   .45 -1.09   0  8  1.719077568134173  5
               3.226876440418037 653  2.61  3.04   -.6  -1.9  -1.9   0 46  3.505196804064164  6
              -1.639863325627885 654 -2.04 -4.16   .04  1.48   .44   0 47 -3.737137223488813  7
              -1.073779734353744 655  4.23    .3  -.76  -.91  -.65   0  1  2.334665259623833  8
              -.7707598557843998 656 -1.97  -3.8 -1.68  1.28  -.62   0  2 -4.510905558260204  9
               .1447530739194685 657  2.52  3.79 -1.81  -.78  -.18   0 27  5.632234115771634 10
               .1178356353986567 658  2.55 -2.27 -3.37  1.69   .15   0 36 -6.712868446318018 11
               2.635474229565091 659  -.06  2.85  1.56 -1.52   .81   0 16 -.4971484039618498 12
              -3.078890081227631 660 -3.11  -.91 -3.06  1.09 -1.67   0 33 -7.488945393473523  1
               .4817352432663817 661  6.13   .35 -2.16   .06 -1.62   0 19  15.58328853888052  2
               .2211978151041967 662 -1.12  3.07  -.73   .16  -.54   0 15 -1.962680118638928  3
               1.991202305673274 663   .59 -2.99  2.13   .41  -.49   0  8 -1.774719304599777  4
              -1.329517653461937 664  1.36   .85  -1.9 -1.54  -.68   0  7  -.137958165980429  5
                 .01391606423699 665 -1.53  2.88 -1.04  1.03 -1.51   0 24  4.176995227578882  6
               .3699056815049282 666  1.54  -4.5 -4.49   .31  -2.6   0 33 -.9031941141664126  7
              -.1181539396678257 667 -6.04   .38  2.88   .75  1.14   0 28 -4.794507615094997  8
               .1582819462867526 668 -3.07 -2.81   .73  1.66   -.5   0 48 -5.034226125211279  9
               1.965128759761292 669  7.75 -2.05  -.32  1.19   .45   0 26  1.760080639112978 10
              -2.397516434496359 670   .56  3.35 -1.23 -2.11    -1   0 46  2.465862669466016 11
              -2.359402434240175 671 -2.17    -3 -2.07   .45   .17 .01 11  .9648062397049453 12
               1.646352401779502 672 -5.77 -3.56  3.13  2.27     3 .01 48 -16.93310993798151  1
              -.8583285517720807 673  -.07   .87  -.03  2.44  2.09 .02 46  -5.86316021298542  2
               1.201286271998179 674  6.96  1.01   1.3   .58   .07 .02 27  15.40650774530879  3
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0  9  2.550189907759083  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 25             -3.125  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 38 -3.037205770690953  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 44  4.504021447721179  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 13  4.549405969284267  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 28                  .  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 45  3.490627020038791  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 46 -3.658107632782269  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 33 -1.366120218579242  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 36  .8333333333333304  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 41 -7.572383073496656  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 12  2.409638554216858  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 42 -1.874003189792659  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 37  1.006124234470693  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 18  2.635021491310042  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 29                  .  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0  2  -14.9038461538462  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 35 -.9306569343065658  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 47  4.410751206064787  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 15 -1.848874598070729  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 10  12.93233082706766  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 22  5.482977038796508  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 26 -3.012808948222987  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 11 -7.781201848998462  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 23  1.793339026473092  2
              -2.428878818318338 601   3.4  1.53  2.74  -.55  1.43   0 14  6.695069993913581  2
              end
              format %tm monthly_date

              Comment


              • #8
                There is something wrong with the data you posted. Observations 75 to the end should be deleted because they repeat observation74 (Added on edit: except for th last three columns)
                That is not the only problem. If you sort by company and monthly_date to have the panel data structure, you will notice that everything is mixed up: for each company you should have a chronological order of dates
                Code:
                . keep in 1/74
                (26 observations deleted)
                
                . sort company monthly_date
                
                . list company monthly_date month
                
                     +----------------------------+
                     | company   monthl~e   month |
                     |----------------------------|
                  1. |       1    2011m10      10 |
                  2. |       1     2012m7       7 |
                  3. |       1     2013m6       6 |
                  4. |       1     2014m8       8 |
                  5. |       2     2011m9       9 |
                     |----------------------------|
                  6. |       2     2014m9       9 |
                  7. |       3     2010m2       2 |
                  8. |       3     2012m1       1 |
                  9. |       3     2013m2       2 |
                 10. |       4     2011m6       6 |
                     |----------------------------|
                 11. |       4     2014m1       1 |
                 12. |       5    2012m12      12 |
                 13. |       7     2011m1       1 |
                 14. |       7     2015m5       5 |
                 15. |       8    2013m10      10 |
                     |----------------------------|
                 16. |       8     2014m5       5 |
                 17. |       8     2015m4       4 |
                 18. |       9     2011m2       2 |
                 19. |       9     2011m3       3 |
                 20. |      10    2012m10      10 |
                     |----------------------------|
                 21. |      11     2013m8       8 |
                 22. |      11    2015m12      12 |
                 23. |      12    2011m12      12 |
                 24. |      12     2012m2       2 |
                 25. |      12     2012m5       5 |
                     |----------------------------|
                 26. |      13     2012m3       3 |
                 27. |      15     2015m3       3 |
                 28. |      16     2012m6       6 |
                 29. |      16     2014m4       4 |
                 30. |      16    2014m12      12 |
                     |----------------------------|
                 31. |      17     2010m5       5 |
                 32. |      17    2010m10      10 |
                 33. |      17     2014m3       3 |
                 34. |      18     2013m3       3 |
                 35. |      18     2013m5       5 |
                     |----------------------------|
                 36. |      19     2015m2       2 |
                 37. |      20    2013m11      11 |
                 38. |      21     2012m9       9 |
                 39. |      22     2013m4       4 |
                 40. |      24     2011m4       4 |
                     |----------------------------|
                 41. |      24     2015m6       6 |
                 42. |      26     2012m8       8 |
                 43. |      26    2015m10      10 |
                 44. |      27    2014m10      10 |
                 45. |      27     2016m3       3 |
                     |----------------------------|
                 46. |      28    2010m12      12 |
                 47. |      28     2015m8       8 |
                 48. |      29    2010m11      11 |
                 49. |      29     2013m1       1 |
                 50. |      30     2011m8       8 |
                     |----------------------------|
                 51. |      32    2012m11      11 |
                 52. |      33     2015m1       1 |
                 53. |      33     2015m7       7 |
                 54. |      35     2011m5       5 |
                 55. |      36     2010m6       6 |
                     |----------------------------|
                 56. |      36     2010m8       8 |
                 57. |      36     2012m4       4 |
                 58. |      36     2013m7       7 |
                 59. |      36    2014m11      11 |
                 60. |      37     2010m4       4 |
                     |----------------------------|
                 61. |      40     2010m9       9 |
                 62. |      41     2010m7       7 |
                 63. |      42    2013m12      12 |
                 64. |      43     2014m2       2 |
                 65. |      44     2010m3       3 |
                     |----------------------------|
                 66. |      46     2014m6       6 |
                 67. |      46    2015m11      11 |
                 68. |      46     2016m2       2 |
                 69. |      47    2011m11      11 |
                 70. |      47     2014m7       7 |
                     |----------------------------|
                 71. |      48     2011m7       7 |
                 72. |      48     2013m9       9 |
                 73. |      48     2015m9       9 |
                 74. |      48     2016m1       1 |
                     +----------------------------+
                Last edited by Eric de Souza; 11 Dec 2020, 05:10.

                Comment


                • #9
                  Your dataset is not that big. Type -browse- in Stata and examine your data. This, of course, is much easier if your dat is first sorted properly as I did above.

                  Comment


                  • #10
                    Thank you. I just double checked with my data and found out that once I created my month variable it automatically puts it in that order. I reranged the order by using
                    Code:
                    xtset company monthly_date

                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input double(logdiff_fintech_funding mktminusrf smb_5 hml rmw cma) byte company double(ri exreturn) float month
                    -2.428878818318338   3.4  1.53  2.74  -.55  1.43 1  1.079242090318634   1.0792420903186335  2
                     4.750675543873377  6.31  1.85  2.01   -.9  1.67 1   7.86393930364869    7.863939303648687  3
                    -1.547824874555269     2  5.03  3.12   .49  1.69 1  7.512007394694056    7.512007394694056  4
                    -2.377775945715615 -7.89  -.08 -2.32  1.38  -.18 1 -7.985979824222703   -7.985979824222701  5
                     2.033946504409595 -5.56 -2.59 -4.27  -.34 -1.48 1 -6.335626764257626  -6.3356267642576265  6
                     1.866966321771243  6.93   .13   .04   .32  2.03 1  2.881855746293185   2.8818557462931853  7
                    -6.230064946559605 -4.77 -3.07 -1.51   .34 -2.13 1  -9.47372995462771    -9.47372995462771  8
                     5.650530448089943  9.54  3.71 -2.94  -.01   .39 1  6.938139934459893    6.938139934459892  9
                      .453532778924937  3.88   .72 -2.23  1.46  -.16 1  -1.05813682753868  -1.0581368275386804 10
                    -2.051943886966359    .6  3.54  -.58   -.1  1.76 1 -.2466604777739863   -.2466604777739864 11
                     2.453635974122106  6.82  1.03  3.47 -3.44  3.44 1  14.13006373515285   14.130063735152843 12
                    -2.555251514231911  1.99 -2.38   .68 -1.07    .8 1 -.7969297791341908   -.7969297791341909  1
                    -.3940574407002404  3.49  1.76  1.73 -1.76   .72 1  .5468279827189715    .5468279827189714  2
                     .9019179029163964   .45  2.66 -1.16  1.21  -.03 1  .9523648032545907    .9523648032545909  3
                    -3.366182863817053   2.9  -.41 -2.15   .96 -1.28 1  .5892439640544306    .5892439640544306  4
                     3.801343710610448 -1.27  -.69 -2.12  2.02 -1.46 1  -1.49001583687659  -1.4900158368765897  5
                     .5375060083539553 -1.75   .09  -.26  2.16  -1.4 1 -2.242232233723338  -2.2422322337233376  6
                    -.9872492784416207 -2.36 -1.38 -1.18  2.41 -1.75 1 -3.803201280158997   -3.803201280158997  7
                     .6191782687064706 -5.99 -3.39 -1.58  2.79  -.23 1 -10.01027367894514  -10.010273678945138  8
                      .263701731990106 -7.59  -3.9  -.98  1.71   .24 1 -9.691976652945483   -9.691976652945483  9
                    -1.255992779152897 11.35  3.72  -.96 -1.42  -.86 1  14.10180765195524   14.101807651955239 10
                    -7.328765598425764  -.28  -.34  -.18  1.46  1.52 1 -.7010521563359489   -.7010521563359488 11
                     6.918695219020471   .74  -.36  1.57   .59  2.44 1   2.80698102953636    2.806981029536361 12
                     1.664472961319299  5.05  2.35 -2.14 -1.05 -1.41 1  4.812300227465119   4.8123002274651165  1
                    -4.488823618117669  4.42 -1.54   .01  -.17  -.03 1  4.929256079524911    4.929256079524911  2
                     2.808398174936492  3.11   -.3  -.06   .25   .77 1  6.134441796438536    6.134441796438538  3
                    -.1262357447864098  -.85  -.66   -.2   .96   .72 1 -.6589440873023984   -.6589440873023982  4
                     .4387329863579144 -6.19   -.2   .08  1.98  2.37 1 -5.232003502156303   -5.232003502156304  5
                     .6944331180936318  3.89   .99   .54 -1.48   .37 1  3.161005632020767   3.1610056320207667  6
                    -.8876966737515692   .79 -2.74   .01   .68   .12 1 -2.194379715301951  -2.1943797153019506  7
                     1.840011420252095  2.55   .61    .6  -.77  -.69 1  3.209782285250071   3.2097822852500713  8
                    -.6554042290035031  2.73   .69  1.56 -1.14  1.57 1  3.744035044489593   3.7440350444895922  9
                    -.2497564922306408 -1.76   -.8  4.16 -1.35  2.28 1 -.0112728353654932 -.011272835365493195 10
                    -2.997485122381406   .78   .41 -1.12   .94   .93 1 -1.707135468131021  -1.7071354681310214 11
                     2.968343045907073  1.18  1.91  3.26 -1.75   .88 1  3.042648155235065   3.0426481552350655 12
                     .2701289866054237  5.57   .57  1.34 -1.88  1.47 1  4.353588346029981     4.35358834602998  1
                     .1509605075700726  1.29  -.35   .28  -.96   .49 1  1.795811335142117    1.795811335142118  2
                    -1.062582825088892  4.03    .9  -.07   .13  1.21 1  4.731694854308732    4.731694854308733  3
                     2.455217987516834  1.56 -2.32   .35   .04   .39 1 -1.228710327935455  -1.2287103279354548  4
                    -.6101666516017357   2.8  2.27  1.33  -.71  -.83 1  4.940060638818191    4.940060638818192  5
                    -.8187397318572058  -1.2  1.33   -.4  -.47   .01 1  2.524169010641897   2.5241690106418964  6
                     .1706158923222114  5.65  1.81   .71 -1.43   .53 1  7.810874448103843    7.810874448103845  7
                    -.7756070164821449 -2.71  -.03 -2.48   .85 -2.13 1 -3.497821482444668  -3.4978214824446687  8
                     1.726891305749435  3.77  2.72 -1.57   -.1 -1.32 1  1.662269053409684    1.662269053409685  9
                     .3957065823815764  4.18 -1.57  1.36  2.83   .89 1  3.530331927754367    3.530331927754367 10
                    -1.548639224836185  3.12  1.47  -.38   .77   .12 1  5.958017535781948    5.958017535781951 11
                    -1.181443691265908  2.81  -.44   -.2  -.57   .07 1  1.758179600545098   1.7581796005450971 12
                    -.0883624242566112 -3.32   .56 -1.88  -4.5 -1.42 1 -3.509387301462624  -3.5093873014626227  1
                     1.654120853093416  4.65   .16  -.49  -.49   -.4 1  2.497577726394331   2.4975777263943297  2
                     .7675383150229624   .43 -1.23   4.6  1.76  1.91 1  4.418488481502361    4.418488481502362  3
                     .7337002959205572  -.19 -4.21  1.62  2.85  1.09 1 -5.144931450627418  -5.1449314506274195  4
                    -1.300090055657543  2.06 -1.83  -.38   .45 -1.09 1 -.1524946883270472  -.15249468832704713  5
                     3.226876440418037  2.61  3.04   -.6  -1.9  -1.9 1  5.056250663074426    5.056250663074427  6
                    -1.639863325627885 -2.04 -4.16   .04  1.48   .44 1 -3.606526297369947   -3.606526297369947  7
                    -1.073779734353744  4.23    .3  -.76  -.91  -.65 1  2.334665259623833   2.3346652596238338  8
                    -.7707598557843998 -1.97  -3.8 -1.68  1.28  -.62 1 -2.045957417917509   -2.045957417917509  9
                     .1447530739194685  2.52  3.79 -1.81  -.78  -.18 1  3.921821214508064    3.921821214508063 10
                     .1178356353986567  2.55 -2.27 -3.37  1.69   .15 1  .2556962153253985    .2556962153253986 11
                     2.635474229565091  -.06  2.85  1.56 -1.52   .81 1  1.699910054766814   1.6999100547668136 12
                    -3.078890081227631 -3.11  -.91 -3.06  1.09 -1.67 1 -9.063475876310159   -9.063475876310163  1
                     .4817352432663817  6.13   .35 -2.16   .06 -1.62 1  7.821358748819074    7.821358748819076  2
                     .2211978151041967 -1.12  3.07  -.73   .16  -.54 1  1.178161237891585    1.178161237891585  3
                     1.991202305673274   .59 -2.99  2.13   .41  -.49 1  1.169923120498791   1.1699231204987903  4
                    -1.329517653461937  1.36   .85  -1.9 -1.54  -.68 1  2.282959490396854   2.2829594903968538  5
                       .01391606423699 -1.53  2.88 -1.04  1.03 -1.51 1  4.042932941219418    4.042932941219419  6
                     .3699056815049282  1.54  -4.5 -4.49   .31  -2.6 1 -.4668957188768061   -.4668957188768061  7
                    -.1181539396678257 -6.04   .38  2.88   .75  1.14 1 -5.438906417704657   -5.438906417704657  8
                     .1582819462867526 -3.07 -2.81   .73  1.66   -.5 1  -1.03380138198852  -1.0338013819885195  9
                     1.965128759761292  7.75 -2.05  -.32  1.19   .45 1  4.103701862358857    4.103701862358857 10
                    -2.397516434496359   .56  3.35 -1.23 -2.11    -1 1  4.884271693531828    4.884271693531826 11
                    -2.359402434240175 -2.17    -3 -2.07   .45   .17 1 -5.998214832502895   -5.998214832502895 12
                     1.646352401779502 -5.77 -3.56  3.13  2.27     3 1 -9.570953046717952    -9.57095304671795  1
                    -.8583285517720807  -.07   .87  -.03  2.44  2.09 1 -3.224477640041395  -3.2244776400413957  2
                     1.201286271998179  6.96  1.01   1.3   .58   .07 1  7.358411454974729     7.35841145497473  3
                    -2.428878818318338   3.4  1.53  2.74  -.55  1.43 2  -14.9038461538462   1.0792420903186335  2
                     4.750675543873377  6.31  1.85  2.01   -.9  1.67 2  8.772742681047772    7.863939303648687  3
                    -1.547824874555269     2  5.03  3.12   .49  1.69 2  5.619839471199241    7.512007394694056  4
                    -2.377775945715615 -7.89  -.08 -2.32  1.38  -.18 2 -12.43110815111477   -7.985979824222701  5
                     2.033946504409595 -5.56 -2.59 -4.27  -.34 -1.48 2 -6.662716462092019  -6.3356267642576265  6
                     1.866966321771243  6.93   .13   .04   .32  2.03 2 -18.01929469655549   2.8818557462931853  7
                    -6.230064946559605 -4.77 -3.07 -1.51   .34 -2.13 2 -13.03805396069644    -9.47372995462771  8
                     5.650530448089943  9.54  3.71 -2.94  -.01   .39 2  12.93086977856836    6.938139934459892  9
                      .453532778924937  3.88   .72 -2.23  1.46  -.16 2 -6.991575267138257  -1.0581368275386804 10
                    -2.051943886966359    .6  3.54  -.58   -.1  1.76 2 -2.587763505524829   -.2466604777739864 11
                     2.453635974122106  6.82  1.03  3.47 -3.44  3.44 2    25.826417302189   14.130063735152843 12
                    -2.555251514231911  1.99 -2.38   .68 -1.07    .8 2 -1.953753199899981   -.7969297791341909  1
                    -.3940574407002404  3.49  1.76  1.73 -1.76   .72 2  1.908535113442489    .5468279827189714  2
                     .9019179029163964   .45  2.66 -1.16  1.21  -.03 2 -2.394001810935897    .9523648032545909  3
                    -3.366182863817053   2.9  -.41 -2.15   .96 -1.28 2 -12.29777807612272    .5892439640544306  4
                     3.801343710610448 -1.27  -.69 -2.12  2.02 -1.46 2 -5.240232404411508  -1.4900158368765897  5
                     .5375060083539553 -1.75   .09  -.26  2.16  -1.4 2 -3.270575104270688  -2.2422322337233376  6
                    -.9872492784416207 -2.36 -1.38 -1.18  2.41 -1.75 2  9.105746602899874   -3.803201280158997  7
                     .6191782687064706 -5.99 -3.39 -1.58  2.79  -.23 2 -16.62784658201427  -10.010273678945138  8
                      .263701731990106 -7.59  -3.9  -.98  1.71   .24 2 -22.14350681319415   -9.691976652945483  9
                    -1.255992779152897 11.35  3.72  -.96 -1.42  -.86 2  11.27604389951129   14.101807651955239 10
                    -7.328765598425764  -.28  -.34  -.18  1.46  1.52 2  .3072477726944403   -.7010521563359488 11
                     6.918695219020471   .74  -.36  1.57   .59  2.44 2  12.55089107389768    2.806981029536361 12
                     1.664472961319299  5.05  2.35 -2.14 -1.05 -1.41 2   1.90504628247238   4.8123002274651165  1
                    -4.488823618117669  4.42 -1.54   .01  -.17  -.03 2  5.432489451476787    4.929256079524911  2
                     2.808398174936492  3.11   -.3  -.06   .25   .77 2   13.8513701295092    6.134441796438538  3
                    end

                    I cannot use:
                    Code:
                     xtset company month, monthly
                    because of repeated time values within the panel.

                    This means if I want to use time fixed effects I should hold i.monthly_date?

                    While i.month should lead to a wrong coef.?
                    Last edited by Marius Bauer; 11 Dec 2020, 06:31.

                    Comment


                    • #11
                      But why did you get rid of monthly_date? That is your time variable which identifies each period (is unique for each period) whereas month is not.

                      On Edit: your month variable serves no purpose as far as i can see. Drop month (or rather give it another name) and rename monthly_date to month. Not that you have to rename it but it is shorter.
                      Your panel structure is identified by company and by monthly_date
                      Last edited by Eric de Souza; 11 Dec 2020, 06:48.

                      Comment


                      • #12
                        thank you very much. I accidentily did not keep monthly_date. When i was doing dataex I wanted to keep only relevant variables and deleted it by accident.

                        Comment

                        Working...
                        X