Announcement

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

  • Why some control variables are dropped when I run a regression?

    Dear Stata Users,

    I have the following problem. When I run the regression as specified below my variable "d" and "i" are dropped:

    Code:
    reghdfe y a b c d e f g h i j, ab( industry fyear) vce(cluster gvkey)
    However, when I run regression using the code below nothing is dropped:

    Code:
    reg y a b c d e f g h i j i.industry i.fyear, vce(cluster gvkey)
    I thought that both estimation should lead to same results, but what I get is different. I attach a sample of data to understand what kind of data I have. The sample is pretty small thus, it is impossible to run "reghdfe" command. Can anyone explain me what is the problem, please?


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long gvkey double fyear float(g c i) byte industry float(y b f h j a e d)
    1004 1996  6.198286 .14575116 0 10  .6421934 1.1670092   .02176793  .2216945            0      20.6   .001643579  .01068376
    1004 1997   6.06051  .1543568 0 10  .6084191 1.3271438   .04309609  .3866963            0 15.558333  .0013579838 .009689922
    1004 1998  5.986406  .2231196 0 10  .7718859 1.1737745   .04253913    .43845            0        15  .0010117558  .00956023
    1004 1999  6.005518  .1931751 0 10  .9570713 1.1157874   .01383235  .6116424            0        15  .0008473565 .009451796
    1004 2000  6.055693 .17841566 1 10  .9500433  .8534871   .06220395 .54848164            0        15   .000720369  .00929368
    1004 2001  7.025525 .21986166 1 10  .9289029  .7305889  -.04746714  .7052776  -.023762355        15  .0007418485 .011210762
    1004 2002  7.012822 .25137508 0 10 1.2834938  .9492987   .04890601  .6708933  -.027913507 15.166667   .000889821 .011160715
    1004 2003  7.459666  .2385747 1 10  .9899191 1.0752404   .02122277  .4158287  -.020995585        17  .0011152189 .011415525
    1004 2004  7.387214  .4020428 1 10   .778831 1.1470801  .071815275  .3976725  -.027012004 12.958334  .0009360462 .010504202
    1004 2005  7.183852  .5648304 1 10  .6803353 1.1998214  -.05528591  .3535434  -.014141532    27.875  .0008638606 .011299435
    1004 2006  7.089853  .4018006 1 10   .593267 1.1826457   -.0216986  .3613859   -.01301852    22.125  .0007991635 .011454754
    1004 2007  6.990122  .3374212 1 10  .8935324  1.305088  .015853763  .7383251  -.009553527    18.125  .0007201883 .011682243
    1004 2008  6.927704   .280715 1 10 1.0660111 1.0282017    .0473205  .5276916  -.017419824    15.875  .0006946016 .015698588
    1004 2009  6.849563  .3665982 0 10  .9798111  .9495602   .11118314   .422771   -.01975028   14.3125  .0010070831 .015082956
    1004 2010  5.396974  .2368699 0 10  .8884209 1.3133016   .07234841  .4521519  -.010943655 12.321428  .0009334664 .013927577
    1004 2011  5.313925  .2032794 1 10 1.2088646 1.1682166   .05530053  .4200464   -.02513603     13.44  .0008223532  .01485884
    1004 2012  5.310477 .23935854 0 10 1.0640327 1.0446383  .074192055  .3026769  -.019888625 10.583333  .0007734007  .01305483
    1004 2013  5.245927 .17233406 0 10 1.0176708   .939043   .06542187  .3322792   -.01332121 10.954545    .00067975 .012626262
    1004 2014  6.214704 .15596236 0 10  .8827152  .7834398 -.019549897  .3079313   -.02666667        11 .00056234695 .011890606
    1013 2002  8.321442 .13910107 0  1  .6829544 .43603295  .024202904  .9282407  -.012847404 15.166667  .0009728841 .011160715
    1013 2003   7.85847 .23123246 1  1   .472948  .7379975  .033997554  .7301185  -.016346673        15  .0010656086 .011415525
    1013 2004    6.8807  .2401816 1  1  .5580432 1.0143559  .002390315  .5022993   -.00945312 13.158334    .00089606 .010504202
    1013 2005  6.788796  .1923098 1  1  .5493866  1.490756   .04103354  .4548816  -.016677525 13.541667  .0008344221 .011299435
    1013 2006  6.740957 .19932663 1  1  .6672375 1.0963907   .05674267  .3609815    -.0063299 14.166667   .000774268 .011454754
    1013 2007  6.653339 .26965496 1  1  .5969584 1.0314378   .08799802  .3976329  .0015299184 11.458333  .0006815634 .011682243
    1013 2008  7.576073 .26374537 1  1 1.1217898 1.1014975   .09950136  .6186197  -.007339927 10.083333   .000762744 .015698588
    1013 2009 8.1798725  .2985752 0  1  .7493402  .6843587   .04159292  .6890941  -.009973207  8.666667   .001100561 .015082956
    1013 2010  6.982082  .3852441 0  1  .6477264 1.1604294   .10166717  .3634293   -.01356392 10.818182  .0009095285 .013927577
    1021 1997  9.846075  .6136998 0 30  .7580069 1.0142353   .27016488  .8539172            0 24.499075     .0013258 .009689922
    1021 1998 11.488844  .3661151 0 30  .9612135  .9115766  -.03207253 1.1125025            0 22.320833  .0009909763  .00956023
    1021 1999  11.71965  .6010197 0 30 1.1632849  .8696296  .017308826  1.247252            0   21.6625   .000833301 .009451796
    1034 1996  7.196516  .2846989 0 13  .8226163  .9333861   .03909724  .3851183            0        25    .00148182  .01068376
    1034 1997  6.271467  .3382001 0 11  .6689221 1.0290096   .05047709   .405334            0 24.916666  .0011417317 .009689922
    1034 1998  6.100126  .3301407 0 11  .5701097  1.208472     .089663   .314932            0 26.666666  .0009192395  .00956023
    1034 1999  5.913328  .6212426 0 11  .6749921 1.2114826    .0769449  .4647437   -.02947686 24.791666    .00075155 .009451796
    1034 2000  5.501762  .7284945 1 11  .6373071 1.2298486  .028548626  .5461127            0 25.583334    .00070436  .00929368
    1034 2001  6.611051  .2851371 1 11  .8949319 1.0823673  .074131526 .51649714   -.04148103    22.525  .0008433457 .011210762
    1034 2002  6.608616 .26189217 0 11 1.2039704  1.262333   .06786588  .6128323  -.008750834      17.5  .0010115434 .011160715
    1034 2003  5.277863 .27360022 1 11 1.0383857 1.0540502   .06835228  .4066382    .04112193   15.7125  .0010331325 .011415525
    1034 2004   6.31967  .2160992 1 11  .9942163 1.0325257   .07992296 .42664465    .08064608   14.1875  .0008818614 .010504202
    1034 2005  5.431157 .23490778 1 11  .7224447  .4133074   .12340344  .4061404   .029476717 17.229166  .0008279722 .011299435
    1034 2006   5.58317 .16981913 1 11  .7466138 1.1810114  .026446624  .3685225    .06281013      17.8  .0007585493 .011454754
    1034 2007  7.764644 .09624628 1 11  .8948778  1.104916   .05067841 .24631956    .05459006      12.2  .0006765461 .011682243
    1036 1999  5.266032 .27062204 0 12  1.066985 1.0633367   .08517072  .3148709            0 11.051666    .00075155 .009451796
    1038 1996  8.027528  .4926955 0  3  .8012618 1.1394268   .27732295 .39965925            0      17.5  .0017079517  .01068376
    1038 1997 8.8081875  .2010124 0  3  .6956688  1.129667    .1264235  .5050235            0 19.083334   .001410056 .009689922
    1038 1998  8.753667 .21488856 0  3  .7990577  1.212479   .08440398  .4985398            0    21.175  .0010612312  .00956023
    1038 1999  8.698174 .17775317 0  3  .9518452 1.1365716   .09124143  .9601218            0 13.558333  .0008741743 .009451796
    1038 2000  8.849781  .2652055 1  3  .8230169 1.0410123   .03655604  .7333021            0 14.083333  .0007307217  .00929368
    1038 2001  8.462026  .1849345 1  3  .8629745  1.104301   .09610662  .5407371   -.01326407        15  .0007253578 .011210762
    1038 2002  8.335834 .15700454 0  3  .9847959 1.3354917   .10064886 .35991305  -.005881217  8.958333  .0008666087 .011160715
    1038 2003 8.3184805  .6012077 1  3  .8407105   .995116   .12286535 .26329944  -.001322904       8.5  .0010885568 .011415525
    1045 1996  4.926919 .10391614 0 10  .8970879 1.0498521    .1388832 .27936104            0        10    .00148182  .01068376
    1045 1997  4.883658 .10285097 0 10  .8098123 1.0460204   .14245987 .29136774            0  8.366667  .0011417317 .009689922
    1045 1998  4.817433 .09687072 0 10  .8855592  1.034195   .15276118  .4392747            0  8.533334  .0009192395  .00956023
    1045 1999  4.827485 .10309393 0 10   .887993  .9231971     .101511  .4327255            0      8.75    .00075155 .009451796
    1045 2000  4.758995 .13574487 1 10 1.0486891 1.1112803   .12890786 .51182884            0  7.916667    .00070436  .00929368
    1045 2001  5.552554  .1064688 1 10  1.062368  .9624423  .019494144  .4825249 -.0044456623  8.541667  .0008433457 .011210762
    1045 2002  5.731862 .09763461 0 10  .9975878  .9122502 -.033829663    .80065   -.03555027  8.583333  .0010115434 .011160715
    1045 2003  5.761844 .10436606 1 10  .9355487 1.0081508   .01985661  .9045359  -.026764406  7.208333  .0010331325 .011415525
    1045 2004  5.785875 .12626468 1 10  .9246221 1.0690941   .02444596 .56725377   -.02307719    6.6875  .0008818614 .010504202
    1045 2005   5.77018 .13546236 1 10  .8418692 1.1108608   .03558892 .48650345  -.033192065        13  .0008279722 .011299435
    1045 2006  4.895624 .13846496 1 10  .7991756 1.0893685   .06573996  .5022422   -.04429576         6  .0007585493 .011454754
    1045 2007   4.84094 .14339505 1 10  .9713714 1.0147587  .066392176  .5074719    .02345035 19.139166  .0006765461 .011682243
    1045 2008  5.862623 .12202184 1 10    .80984  1.037998  -.04879073  1.030656   -.12619662 25.083334  .0008228951 .015698588
    1045 2009  5.860704 .13366649 0 10  .8076021   .838046   .03694141  .8323458   -.10708389 22.916666  .0010542768 .015082956
    1045 2010   5.83002 .12797599 0 10  .7931566 1.1131195   .04878528  .5005696   -.10981346       2.1  .0008844222 .013927577
    1045 2011  5.820522 .14982237 1 10  .7674004 1.0835363   .02710459  .7161176   -.15113264         3   .000780789  .01485884
    1045 2012  5.845049 .16866033 0 10  .7401564 1.0346766   .05363133  .1663352   -.12675457         3   .000721238  .01305483
    1045 2013  5.431897  .1706839 0 10  .8193253 1.0747133  .028711187  .3460524   -.04806282    28.875  .0006052191 .012626262
    1045 2014 3.1949916 .16441144 0 10  .5529742 1.5966607   .07285113  .3852571   -.10415572     44.74 .00051429373 .011890606
    1050 1996 10.386128  .3504654 0 12  .4974858 1.1675164  .012724118   .922819            0 22.333334    .00148182  .01068376
    1050 1997 10.910416  .3763798 0 12  .4415233  1.475528    .2239974  .8131528            0        23  .0011417317 .009689922
    1050 1998 10.037476 .19709544 0 12  .4736617 1.8155668  -.05436573  .8309203            0 17.041666  .0009192395  .00956023
    1050 1999  9.997805  .3888539 0 12  .8150489  .9044803  -.05408724  .8893306            0        13    .00075155 .009451796
    1050 2000 10.700335   .320147 1 12  .9357916  3.764018    .0515145  .8429219            0        13    .00070436  .00929368
    1050 2001 10.615652   .174635 1 12  .7076781 1.0131044    .0783956  .6977643   -.01295493 12.333333  .0008433457 .011210762
    1050 2002 10.695136   .397152 0 12   .848557  .8668374   .06979068  .5690974  -.018531611 11.347222  .0010115434 .011160715
    1050 2003  10.77963  .4065734 1 12  .8297303  .8641176  .034128156  .6510108  -.021723283    11.625  .0010331325 .011415525
    1050 2004 10.739077  .5007769 1 12  .6155913 1.0177085   .04573067  .6675558  -.017494993 14.946428  .0008818614 .010504202
    1050 2005  10.70977  .3997813 1 12  .4589422 1.1752299   .05952902  .6023861   -.01843823 15.583334  .0008279722 .011299435
    1050 2006  9.488387  .3279868 1 12   .417674 1.6604187   -.0967366 .58406126   -.02025701 14.311508  .0007585493 .011454754
    1050 2007  8.568949  .2759072 1 12  .4428369 1.7431644   .06263848  .6125492    -.0138499  13.83712  .0006765461 .011682243
    1050 2008  8.584995  .2736984 1 12  1.089423  .9234466   .05259232  .7774599    -.0275211 15.966666  .0008228951 .015698588
    1050 2009  9.834237  .4026526 0 12  .7584894  .6378677   .12408242  .7541596  -.026072374   16.8125  .0010542768 .015082956
    1050 2010  8.860461  .6315836 0 12   .598528 1.0116343   .03790234 .47264585  -.021499913 10.672222  .0008844222 .013927577
    1050 2011   7.42163  .3515422 1 12  .6786334  .9899717   .11683224 .43550175  -.029617494 14.316667   .000780789  .01485884
    1050 2012  7.183993  .3270205 0 12   .468524  .9702569   .21209906   .356545  -.024568563 11.795834   .000721238  .01305483
    1050 2013  6.542821  .3585493 0 12 .58932936 1.4610447    .2569604   .388982  -.002788808        20  .0006052191 .012626262
    1050 2014  6.424712 .26572967 0 12  .6461024 1.3339803   .04666089    .34191  -.015978666        18 .00051429373 .011890606
    1055 1996   8.52476 .06239302 0  2  .7634674  .8524424  -.13604979  .6584575            0 11.458333    .00148182  .01068376
    1056 1996 10.043566 .11398792 0  1  .6455593 1.0457581   .06266682 .56957924            0 23.375164   .001615722  .01068376
    1056 1997  8.977699 .07738095 0  1   .736703  1.268022   .10754105   .623451            0        30     .0013258 .009689922
    1056 1998  8.427081 .13074987 0  1 .57096946 1.2604693    .1685812  .6989759            0        30  .0009909763  .00956023
    1056 1999   8.31446 .13502447 0  1  .3869433 1.3217455   .09168339  .6170912            0        30   .000833301 .009451796
    1056 2000   7.90638  .2022348 1  1  .1740207 1.1834453   .08861127 1.0825646            0      32.5   .000716845  .00929368
    1056 2001  7.727344  .1712505 1  1 .45513785 1.2521676    .1898137 1.0419106 -.0004963707  40.83333  .0007525573 .011210762
    1056 2002   8.60405   .090686 0  1   .655282  .8703911   .05194165  .7921726   .005906458        25   .000905575 .011160715
    1056 2003  7.706922  .0442023 1  1  .6192387  1.439936    .0671471  .6056529    .01154209 21.333334  .0011168079 .011415525
    1056 2004  7.315645 .29206565 1  1  .4653152 1.4192234   .07289423  .4830334    .02065141 17.416666  .0009240564 .010504202
    end

  • #2
    The output of help reghdfe tells us that it "drops singleton observations" and when it does that, reghdfe informs the user with a message like
    Code:
    (dropped 1 singleton observations)
    Was that the case for your model? If so, you will find that regress was run on more observations than reghdfe, and that's a path to the difference. Perhaps the following would yield similar results for both regressions.
    Code:
    reghdfe y a b c d e f g h i j, ab( industry fyear) vce(cluster gvkey)
    generate inhdfe = e(sample)
    regress y a b c d e f g h i j i.industry i.fyear if inhdfe, vce(cluster gvkey)

    Comment


    • #3
      Thank you very much for your reply. It writes the following:

      Code:
      (converged in 6 iterations)
      note: d omitted because of collinearity
      note: i omitted because of collinearity
      But if collinearity the case should not "d" and "i" be dropped even when I use "reg" with "i.fyear i.industry"?

      "d" and "i" are changing within the year, but not within the industry or firm (gvkey)

      Comment


      • #4
        Cross-posted at https://stackoverflow.com/questions/...trol-variables

        Please note our policy on cross-posting, which is that you tell us about it.

        Comment

        Working...
        X