Announcement

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

  • Least Square Dummy Variable (LSDV) in Stata

    I am working on a panel of 59 banks picked from 12 countries. My time period spans from 2009 till 2015. My objective is to figure out which determinants impact profit of banks. My dependent variable is therefore profit which takes the abbreviation 'nim' in my commands which I have pasted below. All other variables are explanatory variables. Country names represent country dummies.
    I now need to perform 'Least Square Dummy Variables (LSDV) ' on this panel data. I have learnt from various textbooks that 'LSDV' is the other name for 'fixed effect estimation'. I need to know which of the following three commands performs LSDV in my panel data.

    Command # 1:
    Code:
    . xtreg nim nir cr lta otoi nlta ooiti eata car bm inf pcgg cpi Nigeria SriLanka Bangladesh India Kenya M
    > alaysia Egypt Philippines China Turkey Thailand,fe
    note: Nigeria omitted because of collinearity
    note: SriLanka omitted because of collinearity
    note: Bangladesh omitted because of collinearity
    note: India omitted because of collinearity
    note: Malaysia omitted because of collinearity
    note: Egypt omitted because of collinearity
    note: Philippines omitted because of collinearity
    note: China omitted because of collinearity
    note: Turkey omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs      =       413
    Group variable: id                              Number of groups   =        59
    
    R-sq:  within  = 0.3481                         Obs per group: min =         7
           between = 0.1971                                        avg =       7.0
           overall = 0.2147                                        max =         7
    
                                                    F(14,340)          =     12.97
    corr(u_i, Xb)  = -0.0951                        Prob > F           =    0.0000
    
    ------------------------------------------------------------------------------
             nim |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             nir |   .0163953    .011685     1.40   0.161    -.0065888    .0393794
              cr |   .0016437   .0009959     1.65   0.100    -.0003151    .0036026
             lta |  -1.106441   .3945453    -2.80   0.005    -1.882498   -.3303838
            otoi |  -.0455696   .0052323    -8.71   0.000    -.0558613   -.0352779
            nlta |  -.0029255   .0072428    -0.40   0.687    -.0171718    .0113208
           ooiti |  -.0466676   .0053673    -8.69   0.000    -.0572249   -.0361104
            eata |  -.0176386   .0077747    -2.27   0.024    -.0329313    -.002346
             car |   .0168051   .0165491     1.02   0.311    -.0157464    .0493566
              bm |   .0007851   .0075308     0.10   0.917    -.0140277    .0155978
             inf |   .0199149   .0167545     1.19   0.235    -.0130407    .0528705
            pcgg |  -.0425883   .0169323    -2.52   0.012    -.0758936   -.0092829
             cpi |  -.0125125   .0130406    -0.96   0.338     -.038163    .0131379
         Nigeria |          0  (omitted)
        SriLanka |          0  (omitted)
      Bangladesh |          0  (omitted)
           India |          0  (omitted)
           Kenya |   .9214237   .7084233     1.30   0.194    -.4720206    2.314868
        Malaysia |          0  (omitted)
           Egypt |          0  (omitted)
     Philippines |          0  (omitted)
           China |          0  (omitted)
          Turkey |          0  (omitted)
        Thailand |  -.8381735   .6967971    -1.20   0.230     -2.20875    .5324025
           _cons |   14.05015   1.784493     7.87   0.000     10.54011    17.56019
    -------------+----------------------------------------------------------------
         sigma_u |  1.7229017
         sigma_e |  .63462076
             rho |  .88053173   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0:     F(58, 340) =    23.04             Prob > F = 0.0000
    
    .
    Command # 2:
    Code:
    . xtreg nim nir cr lta otoi nlta ooiti eata car bm inf pcgg cpi Nigeria SriLanka Bangladesh India Kenya M
    > alaysia Egypt Philippines China Turkey Thailand
    
    Random-effects GLS regression                   Number of obs      =       413
    Group variable: id                              Number of groups   =        59
    
    R-sq:  within  = 0.3348                         Obs per group: min =         7
           between = 0.7206                                        avg =       7.0
           overall = 0.6728                                        max =         7
    
                                                    Wald chi2(23)      =    334.94
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2        =    0.0000
    
    ------------------------------------------------------------------------------
             nim |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             nir |   .0187304   .0115449     1.62   0.105    -.0038972     .041358
              cr |   .0012113   .0009953     1.22   0.224    -.0007396    .0031621
             lta |  -.7070863   .2783553    -2.54   0.011    -1.252653   -.1615198
            otoi |  -.0395627   .0050475    -7.84   0.000    -.0494556   -.0296698
            nlta |    .002645   .0070117     0.38   0.706    -.0110978    .0163877
           ooiti |  -.0439643   .0053437    -8.23   0.000    -.0544377   -.0334908
            eata |  -.0217432   .0078519    -2.77   0.006    -.0371326   -.0063538
             car |   .0230583   .0161679     1.43   0.154    -.0086302    .0547468
              bm |   .0044242   .0077166     0.57   0.566    -.0107001    .0195485
             inf |   .0221639   .0171058     1.30   0.195    -.0113628    .0556907
            pcgg |  -.0461017   .0175316    -2.63   0.009     -.080463   -.0117403
             cpi |   -.021785   .0121113    -1.80   0.072    -.0455228    .0019527
         Nigeria |   3.033168   .5995214     5.06   0.000     1.858128    4.208208
        SriLanka |   .2917484   .5777481     0.50   0.614    -.8406169    1.424114
      Bangladesh |   .2904912   .5843622     0.50   0.619    -.8548377     1.43582
           India |  -.5742879   .5308723    -1.08   0.279    -1.614779    .4662027
           Kenya |   2.126572   .5044502     4.22   0.000     1.137868    3.115277
        Malaysia |  -2.424813   .6493439    -3.73   0.000    -3.697504   -1.152122
           Egypt |  -1.831614   .6096875    -3.00   0.003     -3.02658   -.6366488
     Philippines |  -.6361527    .466915    -1.36   0.173    -1.551289    .2789839
           China |   -1.47036   .8933924    -1.65   0.100    -3.221377    .2806571
          Turkey |   1.160753   .6421596     1.81   0.071    -.0978566    2.419363
        Thailand |  -.3987376   .6466344    -0.62   0.537    -1.666118    .8686425
           _cons |   12.48027   1.468979     8.50   0.000     9.601125    15.35942
    -------------+----------------------------------------------------------------
         sigma_u |  .87351738
         sigma_e |  .63462076
             rho |  .65452757   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------


    Command # 3:

    Code:
     reg nim nir cr lta otoi nlta ooiti eata car bm inf pcgg cpi Nigeria SriLanka Bangladesh India Kenya Mal
    > aysia Egypt Philippines China Turkey Thailand
    
          Source |       SS       df       MS              Number of obs =     413
    -------------+------------------------------           F( 23,   389) =   43.16
           Model |  1217.92882    23  52.9534271           Prob > F      =  0.0000
        Residual |  477.245929   389  1.22685329           R-squared     =  0.7185
    -------------+------------------------------           Adj R-squared =  0.7018
           Total |  1695.17475   412  4.11450183           Root MSE      =  1.1076
    
    ------------------------------------------------------------------------------
             nim |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             nir |   .0244971   .0138858     1.76   0.078    -.0028035    .0517976
              cr |  -.0002709   .0012601    -0.22   0.830    -.0027484    .0022066
             lta |   .0197848   .1800724     0.11   0.913    -.3342522    .3738218
            otoi |  -.0175484   .0053328    -3.29   0.001     -.028033   -.0070637
            nlta |   .0225154   .0078639     2.86   0.004     .0070543    .0379764
           ooiti |  -.0438234   .0069521    -6.30   0.000    -.0574918   -.0301551
            eata |  -.0503858   .0111521    -4.52   0.000    -.0723117   -.0284598
             car |   .0722298   .0180023     4.01   0.000     .0368357    .1076239
              bm |   .0161238   .0127652     1.26   0.207    -.0089736    .0412211
             inf |   .0175698   .0278604     0.63   0.529    -.0372059    .0723456
            pcgg |  -.0524609   .0293188    -1.79   0.074     -.110104    .0051822
             cpi |  -.0428361   .0180001    -2.38   0.018    -.0782257   -.0074465
         Nigeria |    2.65039   .3263086     8.12   0.000     2.008841    3.291939
        SriLanka |   .8536365   .3892656     2.19   0.029     .0883088    1.618964
      Bangladesh |   .8205079   .3720648     2.21   0.028     .0889982    1.552018
           India |  -.3762995   .3591384    -1.05   0.295    -1.082395    .3297957
           Kenya |   2.897395   .3746782     7.73   0.000     2.160747    3.634043
        Malaysia |  -2.140142   .4942142    -4.33   0.000    -3.111807   -1.168477
           Egypt |  -.9467589    .311581    -3.04   0.003    -1.559352   -.3341653
     Philippines |  -.3202755   .2946155    -1.09   0.278    -.8995135    .2589625
           China |  -1.556073   .5554704    -2.80   0.005    -2.648172   -.4639728
          Turkey |   1.475286   .4628376     3.19   0.002     .5653102    2.385263
        Thailand |  -1.002632   .4558766    -2.20   0.028    -1.898923   -.1063418
           _cons |    9.64989   1.527788     6.32   0.000     6.646134    12.65365
    ------------------------------------------------------------------------------
    
    .
    Problem with the first command is that iy is omitting my country dummies. I don't want this to happen. I need to know their sign and significance.
    Confusion with the second command is that it uses xtreg plus it doesn't use -fe- option.
    I read LSDV is simply OLS applied on model that includes country dummies. So, is -xtreg- the right command or is the 3rd command that uses -reg- correct?'

    Please reply! Which among these three commands actually perform LSDV in my model?

  • #2
    Sara:
    even though you can get the same result with -areg-, -xtreg,fe- and -regression-, I would go -xtreg, fe-, because it outperforms the clustered standard errors obtained with the other approaches.
    The following codes consiser -areg-and -xtreg, fe- (but not -regress-, due to bothering -matsize- issues):
    Code:
    . use "http://www.stata-press.com/data/r14/nlswork.dta", clear
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . areg ln_wage hours i.race, abs( idcode) vce(cluster idcode)
    note: 2.race omitted because of collinearity
    note: 3.race omitted because of collinearity
    
    Linear regression, absorbing indicators         Number of obs     =     28,467
                                                    F(   1,   4709)   =       0.67
                                                    Prob > F          =     0.4124
                                                    R-squared         =     0.6249
                                                    Adj R-squared     =     0.5505
                                                    Root MSE          =     0.3204
    
                                 (Std. Err. adjusted for 4,710 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           hours |   .0004474   .0005458     0.82   0.412    -.0006227    .0015175
                 |
            race |
          black  |          0  (omitted)
          other  |          0  (omitted)
                 |
           _cons |   1.658941   .0199551    83.13   0.000      1.61982    1.698063
    -------------+----------------------------------------------------------------
          idcode |   absorbed                                    (4710 categories)
    
    
    
    
    
    . xtreg ln_wage hours i.race, fe vce(cluster idcode)
    note: 2.race omitted because of collinearity
    note: 3.race omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs     =     28,467
    Group variable: idcode                          Number of groups  =      4,710
    
    R-sq:                                           Obs per group:
         within  = 0.0001                                         min =          1
         between = 0.0314                                         avg =        6.0
         overall = 0.0074                                         max =         15
    
                                                    F(1,4709)         =       0.81
    corr(u_i, Xb)  = 0.0976                         Prob > F          =     0.3696
    
                                 (Std. Err. adjusted for 4,710 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           hours |   .0004474   .0004986     0.90   0.370    -.0005301     .001425
                 |
            race |
          black  |          0  (omitted)
          other  |          0  (omitted)
                 |
           _cons |   1.658941   .0182299    91.00   0.000     1.623202     1.69468
    -------------+----------------------------------------------------------------
         sigma_u |   .4229084
         sigma_e |  .32040339
             rho |  .63532952   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      None of the commands shown here implement the LSDV estimator, when you want bank fixed-effects. The command that does this is

      Code:
      regress nim ... i.id
      The results will be identical to those obtained from xtreg with fe option. If countries get omitted because of collinearity then there is probably nothing you can do about it. The reason this does not happen with the two other approaches you have shown is these are not fixed-effects estimators. Here the variances between banks are used to estimate the relationships.

      Note that the differences in standard errors between areg and xtreg that Carlo shows, result because of different assumptions about the number of clusters when the sample increases. You need to know which you want.

      Best
      Daniel

      Comment


      • #4
        So many thanks Carlo and Daniel:

        Daniel, you mean to say that I must go for the xtreg, fe command and let dummy variables be omitted as it can't be helped. Plus, I don't want to create dummies at bank level but at country level.

        Comment


        • #5
          Assuming that id is a bank identifier, it seems odd you get coefficients for some countries at all. I suppose a bank does not change the country it is located in? In this case there might be a coding error in your data.

          Only you can decide which model you want. Think about which variances you want to base your estimates on. If you want to use variances within banks only, thus controlling for any observed and unobserved (time-constant) differences between banks, then you should go with xtreg , fe with banks as panel identifiers. If you want within country effects instead you need to use countries as the panel identifier - or include country indicators like you did in your third approach. This is not clear from your question.

          Best
          Daniel

          Comment


          • #6
            So many thanks, Daniel!

            Comment


            • #7

              Hey Carlo and Daniel, do you have any suggestions what to do for a panel var model with fixed effect estimation?

              Comment


              • #8
                Taulant:
                with no detail at all, I would go -xtreg, fe-.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Thank you for your quick reply Carlo. The problem with this method is that it accepts only one dependent variable and I need to insert a vector of dependent variables. I am trying to estimate the panel var model with fixed effects as in
                  Click image for larger version

Name:	Screenshot 2022-05-13 at 11.19.44.png
Views:	1
Size:	331.0 KB
ID:	1664410
                  the picture. Thank you in advance

                  Comment


                  • #10
                    Taulant:
                    I'm not familiar with this stuff.
                    See: https://journals.sagepub.com/doi/pdf...867X1601600314 The Stata Journal (2016) 16, Number 3, pp. 778–804
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Yes, I already saw it but it does not offer any possibility for fixed effects with OLS. Thnx anyway!

                      Comment

                      Working...
                      X