Announcement

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

  • FGLS regression help

    Hello Stata experts.
    Kindly need your expertise in doing an FGLS regression in panel data.
    I have data with N=250 ant T=95.
    Original Model equation is
    Code:
    Yit = Bi + B1X1 + B2X2 + B3X3 + B4X4 +eit
    I have generated two size related dummy variables D1 and D2 and two interaction terms
    Code:
    D1*X1
    and
    Code:
    D2*X1
    .
    please help me as I am confused in running regression in Stata using the dummies and interaction terms

  • #2
    Zulfiqar, as both N and T are somehow large, you may consider either -xtscc- or -xtreg- (or both for results comparison) with panel fixed effects.

    Code:
    xtset panelvar timevar
    xtscc Y X1 X2 X3 X4 D1 D2 c.D1#c.X1 c.D2#c.X1, fe
    OR/AND

    Code:
    xtset panelvar timevar
    xtreg Y X1 X2 X3 X4 D1 D2 c.D1#c.X1 c.D2#c.X1, fe vce(cluster panelvar)
    A couple of notes:
    1. It's better to control for D1 and D2 in addition to their interactions with X1, to make the model less restrictive.
    2. You may need to control for some sort of time dummies/trends, depending on the nature of your time variable.

    Comment


    • #3
      Fei Wang can I use FGLS in such case?
      secondly, should I use i. operator
      Code:
       
       i.D1#c.X1
      or c. operator
      Code:
       
       c.D1#c.X1
      for dummy variable case?

      Comment


      • #4
        Zulfiqar, if you mean "FGLS" by using -xtgls-, I wouldn't recommend. First, -xtgls- assumes specific structure of autocorrelation (like AR(1)) and estimates could be very wrong if the assumption is violated. Second, -xtgls-, among other commands fitting large T samples (like -xtpcse-), requires small N relative to T -- not your case, while -xtscc- only requires large T and estimates are robust to very general forms of heteroskedasticity and autocorrelation.

        Your second question: If "D1" has already been 0 or 1, then just use c.D1#c.X1.

        Comment


        • #5
          Fei Wang Thank you so much. Its really helping. But I feel I have to include only one dummy variable in the estimation of model. As including both dummies omits one dummy from the regression.

          Comment


          • #6
            zulfiqar ali shah , if your variables are constructed correctly, it's harmless to include both dummies. Stata will automatically drop variables that are perfectly collinear with others -- But please make sure it's not a result from data management errors.

            Comment


            • #7
              Thanks Fei Wang. Your comments are so helpful. But I
              am getting confused with the commands. I can you provide you with a sample data if you could do a sample estimation. It will be very helpful.

              Comment


              • #8
                I am using linear model as given
                Code:
                Rsit = αi + βsSizeit + βmRmt + βrSpreadt + βoOpt + βovOpvt +Exrt + εit
                with the following data sample
                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input double(Rs Rf Rm rExr) float Size byte size float(op opv) byte(D1 D2) float(D1Xop D2Xop D1Xopv D2Xopv SizeXop sizeXopv)
                  .14660347419187544 12.25   .004524711460395734    .005889298529552945  -3.427861 1      .082624  -.001449532 1 0      .082624          0  -.001449532            0    -.28322363   .004968795
                 -.16251892949777494 12.25    .05250593167733974    -.01359760826538379   -3.59038 1    .06410435 -.0027233395 1 0    .06410435          0 -.0027233395            0      -.230159   .009777824
                  .43185186328135927 12.25   .024235228224835058                      0  -3.158528 1    .05605654  -.002461309 1 0    .05605654          0  -.002461309            0     -.1770562   .007774115
                 -.14550758367123814 11.95   -.11165477072789486    .014184634991956381  -3.304036 1     -.157819    .00305687 1 0     -.157819          0    .00305687            0      .5214397  -.010100008
                   -.877881283759284  12.1    .04153086846894846   .0035149421074443707  -4.181917 1   .005134214  -.015657077 1 0   .005134214          0  -.015657077            0    -.02147086     .0654766
                   .8284885284297076  12.1    .07880294585078769   -.003514942107444497 -3.3534286 1    .04171572  -.016210202 1 0    .04171572          0  -.016210202            0     -.1398907    .05435976
                 -.06313303952883631 12.45   -.06947191458360331   .0023446669592540547 -3.4165616 1     -.046014  -.014612198 1 0     -.046014          0  -.014612198            0      .1572097    .04992348
                 -.10660973505825826 12.45   .020202075505599677    .009903955116944805 -3.5231714 1    .09813935  -.005569962 1 0    .09813935          0  -.005569962            0     -.3457618    .01962393
                  .38696163654360466 12.55   .056787838329949714     -.0049979763480906   -3.13621 1   .010476898  -.008002922 1 0   .010476898          0  -.008002922            0    -.03285775    .02509884
                  .00845313571105841 12.55    .05830949726467733   -.001399253959644476 -3.1277566 1   .033093724  -.007980152 1 0   .033093724          0  -.007980152            0    -.10350911   .024959974
                   .1469095185706986 12.75     .0677640234757444  -.0011675424560378123  -2.980847 1     .0981485  -.006617937 1 0     .0981485          0  -.006617937            0     -.2925657    .01972706
                  .08894748601649612  12.9   .027637103684526865                      0 -2.8918996 1    .06430098  -.010858228 1 0    .06430098          0  -.010858228            0    -.18595196   .031400908
                  .03655759573379773  12.9   -.09056449686655774   .0005839416224326983  -2.855342 1    .10181534  -.007648556 1 0    .10181534          0  -.007648556            0    -.29071763   .021839244
                   -.262364264467491  13.4   .045058505521276535   -.004094770272495544  -3.117706 1    .04885787  -.012986895 1 0    .04885787          0  -.012986895            0     -.1523245    .04048932
                   .3062584580247164  13.1    .02078251098440554   -.007058852839624688  -2.811448 1   .070485674  -.013611512 1 0   .070485674          0  -.013611512            0     -.1981668    .03826806
                  -.1884754223683329  13.1  .0054266574700888425    .014650130170849584  -2.999923 1   -.07522164 -.0027215334 1 0   -.07522164          0 -.0027215334            0     .22565913   .008164391
                     -.1261512853269  13.4   .030294145999838224 -.00058190283864856935 -3.1260746 1   -.03676485 -.0045156083 1 0   -.03676485          0 -.0045156083            0     .11492966   .014116128
                 -.07864312731911323 13.48  -.024764698081995145    .007422905806529156 -3.2047176 1    .03749711 -.0012089006 1 0    .03749711          0 -.0012089006            0    -.12016765   .003874185
                  -.0953101798043249 12.95   -.09635515657539187    .007826927617881558  -3.300028 1   -.01599901   .002562184 1 0   -.01599901          0   .002562184            0     .05279718  -.008455279
                   .1823215567939546    13   .060580306242569354   .0020616202468694183  -3.117706 1   -.11090746   .002613537 1 0   -.11090746          0   .002613537            0      .3457769  -.008148241
                 -.12216763397420766 11.55    .00904840320382536   -.010929070532190317  -3.239874 1    .06439947  -.003953656 1 0    .06439947          0  -.003953656            0     -.2086462   .012809347
                  .07786737507762775  11.6   -.02872209782695319    .025129820390917438 -3.1620066 1   .009047456  -.005993918 1 0   .009047456          0  -.005993918            0   -.028608115    .01895281
                  -.0427111180930498 11.85  -.016186195553638098    .012666200833569176 -3.2047176 1  -.028499255  -.006030716 1 0  -.028499255          0  -.006030716            0     .09133206    .01932674
                -.023920183717651842  11.5    .04541453144879637   .0057752270691536454  -3.228638 1    .03329936  -.005849715 1 0    .03329936          0  -.005849715            0    -.10751158    .01888661
                   .1059190188837373 11.65    .08108502413555563    .006842538561402757  -3.122719 1     .1003896  -.005433967 1 0     .1003896          0  -.005433967            0    -.31348845   .016968751
                  .08505524949708082  11.8    .06638262044707946   -.004409178219005883  -3.037664 1  .0021152692  -.012392432 1 0  .0021152692          0  -.012392432            0   -.006425477    .03764404
                  .07410797215372184  11.8    .01647621926471659    .005288685751513486 -2.9635556 1  -.027819676  -.010024305 1 0  -.027819676          0  -.010024305            0     .08244516   .029707586
                  -.1458518770125633 11.82  -.014671393953882665    .027636546203248485 -3.1094074 1    -.1590445     -.010139 1 0    -.1590445          0     -.010139            0      .4945342   .031526282
                  .05623971832287611 11.89  .0010722042434278755     .00989211916900838  -3.053168 1   -.04044961  -.027516743 1 0   -.04044961          0  -.027516743            0     .12349945    .08401323
                                   0 11.85   .054674183235071824 -.00031757794158832997  -3.053168 1    .07059688   -.02714437 1 0    .07059688          0   -.02714437            0     -.2155441    .08287632
                -.048009219186360724 10.35   .054375662556893876                      0  -3.101177 1    .08831114  -.028527133 1 0    .08831114          0  -.028527133            0    -.27386847    .08846769
                 -.01652930195121047 10.25   .003453065396823134    .003698815313457428  -3.117706 1  -.018887725  -.033307258 1 0  -.018887725          0  -.033307258            0     .05888638    .10384225
                  .46478168526458397  9.35    .02968108417083695    .010702022194000002 -2.6529245 1  -.033059873  -.033506706 1 0  -.033059873          0  -.033506706            0     .08770534    .08889076
                   .5284700877456994  9.37   .040871999209619404   .0068643015238994375 -2.1244545 1   .023331635   -.03454456 1 0   .023331635          0   -.03454456            0      -.049567   .073388346
                  .03933941456003251   9.2   .019802201395090254    .007126288872472215 -2.0851152 1  -.000756128   -.03500055 1 0  -.000756128          0   -.03500055            0    .001576614    .07298018
                 -.04243060712970541  9.05   .019762228500559493    .004415471567699105 -2.1275458 1    .03950594  -.033408888 1 0    .03950594          0  -.033408888            0     -.0840507    .07107894
                  .05715841383994883   9.3     .0525826579787443    .005313725971241906 -2.0703874 1   -.03643226  -.034499686 1 0   -.03643226          0  -.034499686            0     .07542889    .07142772
                 .005830920310793144   9.4  -.007198864343579832   .0023413254447794646 -2.0645564 1   -.01196231   -.03562175 1 0   -.01196231          0   -.03562175            0    .024696864    .07354312
                 -.07169585681078386  9.48    .05073830873150066   .0005082592231398354 -2.1362522 1  -.071745165  -.035713717 1 0  -.071745165          0  -.035713717            0     .15326576     .0762935
                -.010044026685333766  9.45    .13945346296657632  .00020323137962444855 -2.1462963 1    -.0192078   -.04219246 1 0    -.0192078          0   -.04219246            0     .04122563    .09055752
                 .031058397019972803     9   -.03817339725153179    .010410969862149086  -2.115238 1    .01780091   -.04260821 1 0    .01780091          0   -.04260821            0    -.03765316     .0901265
                  .08215761857816227   8.9     .1042083546523584    .021388529844400237 -2.0330803 1    .05313267   -.03767586 1 0    .05313267          0   -.03767586            0    -.10802299    .07659806
                 -.09014046723415799     9  -.050674489511587935    .027664952858193335 -2.1232207 1    .05725988   -.04020438 1 0    .05725988          0   -.04020438            0    -.12157536    .08536276
                 -.28071911169653085  9.35   -.01491928868292611    .012369329923812592   -2.40394 1   -.05041157    -.0381746 1 0   -.05041157          0    -.0381746            0     .12118638    .09176946
                  .05247626786781512  9.35    .04229283421292323    .008943340381320454 -2.3514636 1   .004650916    -.0322259 1 0   .004650916          0    -.0322259            0    -.01093646    .07577803
                  .14268764183736654  9.88    .06486570566824236     .01534556967466032  -2.208776 1   .008102591   -.00853758 1 0   .008102591          0   -.00853758            0   -.017896809     .0188576
                   .6741635596266357  9.95    .03870077680290026    -.02902825541987715 -1.5346124 1    .01039187   .004919592 1 0    .01039187          0   .004919592            0    -.01594749  -.007549667
                  -.3711347268244166    10    .05201576915928195    -.06504755652652156 -1.5719185 1  -.011760046    .02568142 1 0  -.011760046          0    .02568142            0    .018485833    -.0403691
                -.060780051301721004 10.03    .06254864024718004   .0035578182383089792 -1.6326985 1   .003195933    .04659363 1 0   .003195933          0    .04659363            0   -.005217995   -.07607335
                 -.18572484992566243  9.97   .028124635612268425   .0003043676785025141 -1.8184234 1   .012646428    .04615115 1 0   .012646428          0    .04615115            0    -.02299656   -.08392233
                 .004535155165391363  9.95 -.0028678142079797825                      0 -1.8138882 1    .02692901    .04522202 1 0    .02692901          0    .04522202            0    -.04884621   -.08202769
                  -.1778068764394281  9.95   .022064510531020314    .001013890383924265  -1.991695 1   -.05775695    .05059287 1 0   -.05775695          0    .05059287            0     .11503422   -.10076558
                 -.08103419002074618  9.97   -.05933385201228054     .03063653266154843 -2.0727293 1  -.026732506    .05339063 1 0  -.026732506          0    .05339063            0     .05540925   -.11066432
                  .12388655437689008  9.95    .03975709430979815    .007343974255758505 -1.9488426 1    -.0858515    .05423296 1 0    -.0858515          0    .05423296            0     .16731104    -.1056915
                 .006195166948925699  9.95     .0216350672941391   .0009751341582062914 -1.9426476 1    -.0973558    .05588834 1 0    -.0973558          0    .05588834            0       .189128   -.10857136
                   -.306558726123487  9.43    .02668307836719809   -.008810629682154807 -2.2492063 1   -.20175895      .056138 1 0   -.20175895          0      .056138            0      .4537975   -.12626594
                 .013889112160667093   9.6   .029476661361997614   -.010378150968713756 -2.2353172 1   -.20148847    .05406909 1 0   -.20148847          0    .05406909            0      .4503906   -.12086157
                  .21677850976133603   8.5    .06950103209281403    .003471364755459004 -2.0185387 1   -.07839753    .04585938 1 0   -.07839753          0    .04585938            0     .15824844   -.09256893
                 -.35881890791557036  8.35  -.023847398524423667    .007398307481444925 -2.3773575 1     .1666658    .04682338 1 0     .1666658          0    .04682338            0     -.3962242   -.11131592
                 -.32383383774949015     8   -.10652082493778539                      0 -2.7011914 1   -.12679125    .03857343 1 0   -.12679125          0    .03857343            0     .34248745   -.10419422
                  .09431067947124142   7.3    .10942364406258306                      0  -2.606881 1    .19239575    .05144932 1 0    .19239575          0    .05144932            0    -.50155276   -.13412224
                  .08250122151174356   6.7  -.020159471694931815   .0015712465178978755 -2.5243795 1   -.01811458   .036852214 1 0   -.01811458          0   .036852214            0     .04572807   -.09302898
                -.033711057342311605   6.9   .039796432805352076    -.00186613028668337 -2.5580904 1   -.03018623    .03702736 1 0   -.03018623          0    .03702736            0      .0772191   -.09471934
                  .17034536574723894  6.85   .038289613910438204  .00029488376878546353  -2.387745 1    -.1968589     .0433008 1 0    -.1968589          0     .0433008            0     .47004884   -.10339127
                  .03084467535109857  6.95   -.02880966598955925    .022833151298218876 -2.3569005 1   .036807228   .037187334 1 0   .036807228          0   .037187334            0    -.08675097   -.08764684
                 .012384059199721622   6.5   -.07282600125459356   .0023986579022866345 -2.3445165 1   -.11255489    .03738443 1 0   -.11255489          0    .03738443            0     .26388678    -.0876484
                  -.1670540846631662   6.3    .05934811440869956    .009062785616720174 -2.5115705 1    .02462757   .032874413 1 0    .02462757          0   .032874413            0    -.06185388    -.0825664
                 -.14555139624107166  6.55   -.06034621481629012   .0009492169673321553  -2.657122 1    -.1049027    .03338884 1 0    -.1049027          0    .03338884            0     .27873927   -.08871821
                -.055119299221079554  6.55    .01724637734277748   -.006663518230770847  -2.712241 1   -.17917776    .03280008 1 0   -.17917776          0    .03280008            0      .4859733   -.08896172
                                   0  6.25  -.047352279785558386                      0  -2.712241 1   -.07024193   .015866406 1 0   -.07024193          0   .015866406            0     .19051304   -.04303352
                                   0  6.25  .0022630339502099977  -.0004776689844823941  -2.712241 1   .035116795   .011280113 1 0   .035116795          0   .011280113            0    -.09524522  -.030594386
                  .06453852113757116  6.25    .05487443446658796  -.0004778972611863072  -2.647703 1    .09646716   .014664778 1 0    .09646716          0   .014664778            0    -.25541636   -.03882797
                 .010362787035546658   6.2   .046584603746249356   .0009555662456686359   -2.63734 1    .19539987   .013268907 1 0    .19539987          0   .013268907            0    -.51533586  -.034994617
                 .030459207484708654     6   .037932037796408476  .00019100372515334829  -2.606881 1    .03222132 -.0037561066 1 0    .03222132          0 -.0037561066            0    -.08399714   .009791722
                 -.12783337150988477  5.85    .04664607998361222  -.0011465699708219997  -2.734714 1 .00012203201 -.0029229405 1 0 .00012203201          0 -.0029229405            0 -.00033372265   .007993407
                   .1622347982272172     6    .04515646806245873   .0010510726685482542  -2.572479 1   -.15671667  .0020464025 1 0   -.15671667          0  .0020464025            0      .4031504  -.005264328
                  .06090875308699252   5.9   .007077560726753021 -.00019102196810708415 -2.5115705 1    .10275915  -.015274336 1 0    .10275915          0  -.015274336            0    -.25808683    .03836257
                 -.04652001563489282   5.9   .018226200445621992   -.003252968808053835 -2.5580904 1    .04236903   -.01628441 1 0    .04236903          0   -.01628441            0    -.10838382    .04165699
                 -.17662353567931688   5.9    -.0161118612769925    .003348484353281573  -2.734714 1  -.015289178  -.015091903 1 0  -.015289178          0  -.015091903            0     .04181153    .04127204
                   .1278333715098848   5.9    .06615730680817226  .00047744092575590367  -2.606881 1    .04427084  -.015776714 1 0    .04427084          0  -.015776714            0     -.1154088    .04112801
                  -.0779615414697118  5.99    .11479221194654912  -.0038259252790373696  -2.684842 1    .11883257  -.015527884 1 0    .11883257          0  -.015527884            0     -.3190467    .04168992
                  .08890148150804617  5.92   .019691073634711634   .0027752541856788447  -2.595941 1   -.01958493   -.02311466 1 0   -.01958493          0   -.02311466            0     .05084132    .06000429
                  .10238874526866873  5.94  -.004593196203063127  .00019111323517306795  -2.493552 1  -.001653518  -.020883944 1 0  -.001653518          0  -.020883944            0    .004123133     .0520752
                 -.06453852113757105  5.99   -.00782503473591572  .00047762335530888685 -2.5580904 1   -.05060082  -.019120844 1 0   -.05060082          0  -.019120844            0     .12944147    .04891285
                  .06453852113757116  5.98   .023498048997486982  -.0005731754073618494  -2.493552 1  -.020718027   -.02179043 1 0  -.020718027          0   -.02179043            0     .05166148    .05433557
                  .05218575317057025  5.99    .02584262516334602   .0003821534392546945  -2.441366 1   -.02751072  -.023860775 1 0   -.02751072          0  -.023860775            0     .06716374    .05825289
                                   0  5.99   -.08292954781568648  .00009551554522762112  -2.441366 1   -.04834761   -.02701212 1 0   -.04834761          0   -.02701212            0     .11803422    .06594647
                 -.07020425867324857     6  -.011986869205713822    .005714301263438635 -2.5115705 1    .09445658  -.023971867 1 0    .09445658          0  -.023971867            0    -.23723437    .06020703
                 -.09032263829328573  5.99   -.11026064244306007  -.0019011412570244187  -2.601893 1    -.0048181   -.02728436 1 0    -.0048181          0   -.02728436            0     .01253618   .070990995
                                   0     6   .028759068257882228    .001426194679585521  -2.601893 1    .09427882   -.02752569 1 0    .09427882          0   -.02752569            0     -.2453034     .0716189
                -.005988041844622669  5.99   -.06810385543755028 -.00019004180976992275  -2.607881 1    .06476406   -.01921018 1 0    .06476406          0   -.01921018            0      -.168897    .05009787
                 -.05134598003862564  5.99   .009875305599902216                      0  -2.659227 1   .035543844   .017727148 1 0   .035543844          0   .017727148            0    -.09451915   -.04714051
                                   0  5.99   .011459107938857686     .04796170309027419  -2.659227 1    .05093208   .019715397 1 0    .05093208          0   .019715397            0    -.13543996   -.05242772
                -.001325651547830314 12.25   .004524711460395734    .005889298529552945  1.9914577 3      .082624  -.001449532 0 1            0    .082624            0  -.001449532      .1645422 -.0028866816
                                   0 12.25    .05250593167733974    -.01359760826538379  1.9914577 3    .06410435 -.0027233395 0 1            0  .06410435            0 -.0027233395      .1276611  -.005423415
                 .008130126083250089 12.25   .024235228224835058                      0  1.9995878 3    .05605654  -.002461309 0 1            0  .05605654            0  -.002461309     .11208998  -.004921603
                 -.15859712281923785 11.95   -.11165477072789486    .014184634991956381  1.8409907 3     -.157819    .00305687 0 1            0   -.157819            0    .00305687    -.29054335   .005627669
                   .0943284707967846  12.1    .04153086846894846   .0035149421074443707  1.9353192 3   .005134214  -.015657077 0 1            0 .005134214            0  -.015657077    .009936343   -.03030144
                 .010521892219428819  12.1    .07880294585078769   -.003514942107444497   1.945841 3    .04171572  -.016210202 0 1            0  .04171572            0  -.016210202     .08117217  -.031542476
                  -.1461370208863516 12.45   -.06947191458360331   .0023446669592540547   1.799704 3     -.046014  -.014612198 0 1            0   -.046014            0  -.014612198    -.08281159   -.02629763
                end
                Please do help me.

                Comment


                • #9
                  I'd like to know your specific questions. If you'd like to run the regression in #8, just replace the variables in #2 with the actual names of your variables.

                  Comment


                  • #10
                    I am looking for
                    1.Impact of oil price returns and oil price volatility on the stock returns
                    2. Oil price and stock relationship using firm size as moderator
                    3. How oil price effect returns of different firms. [ D1 and D2 are two dummy variables for firm size] D1 for Small and D2 for Large
                    Original equation is
                    Code:
                    Xtreg Rs Rf Rm rExr op opv , fe
                    Then I have to form interactions of size and op and size and opv to check the moderated effect of size

                    Comment


                    • #11
                      Code:
                      xtreg Rs Rf Rm rExr op opv D1 c.D1#c.op, fe vce(cluster firmid)
                      You only need D1 or D2. In the case above, the coefficient of c.D1#c.op means the effect of oil price on stock returns for small firms minus the effect for large firms.

                      Comment


                      • #12
                        Will check with this. you are really helpful and kind. Thank you so much

                        Comment

                        Working...
                        X