Announcement

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

  • Help with a gravity model!

    Good morning,

    At the moment I am doing a gravity model for the trade in music. My problem is very simple, the coefficients I am getting are simply too big for a regression over log variables.

    Code:
    note: dexp40 omitted because of collinearity
    note: dimp2 omitted because of collinearity
    
          Source |       SS       df       MS              Number of obs =    4608
    -------------+------------------------------           F( 97,  4510) =  115.74
           Model |   200664.63    97  2068.70752           Prob > F      =  0.0000
        Residual |   80613.966  4510  17.8744936           R-squared     =  0.7134
    -------------+------------------------------           Adj R-squared =  0.7072
           Total |  281278.596  4607  61.0546116           Root MSE      =  4.2278
    
    ------------------------------------------------------------------------------
        lstreams |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           ldist |  -.6587691     .08396    -7.85   0.000    -.8233719   -.4941664
     comlang_off |   2.953035   .2436569    12.12   0.000     2.475348    3.430722
            home |   6.002062   .5270833    11.39   0.000     4.968721    7.035404
           dexp1 |   4.945245   .6250663     7.91   0.000     3.719809    6.170682
           dexp2 |   14.58816   .6283887    23.22   0.000     13.35621    15.82011
           dexp3 |   7.035149   .6104235    11.53   0.000      5.83842    8.231878
           dexp4 |   9.383499   .6109546    15.36   0.000     8.185729    10.58127
           dexp5 |  -1.895036   .6235645    -3.04   0.002    -3.117528   -.6725441
           dexp6 |   11.25079   .6157759    18.27   0.000     10.04357    12.45801
           dexp7 |   14.62706    .618263    23.66   0.000     13.41496    15.83916
           dexp8 |   .6458567   .6256846     1.03   0.302    -.5807919    1.872505
           dexp9 |   13.03582   .6214147    20.98   0.000     11.81755     14.2541
          dexp10 |  -2.044303   .6204987    -3.29   0.001    -3.260784   -.8278211
          dexp11 |   2.191108   .6102339     3.59   0.000     .9947502    3.387465
          dexp12 |    12.5533    .610251    20.57   0.000      11.3569    13.74969
          dexp13 |    5.28296   .6209701     8.51   0.000     4.065554    6.500366
          dexp14 |  -1.749257   .6217986    -2.81   0.005    -2.968287   -.5302275
          dexp15 |   -2.03346   .6207022    -3.28   0.001    -3.250341   -.8165796
          dexp16 |   5.865316   .6107381     9.60   0.000      4.66797    7.062662
          dexp17 |   14.32632   .6105227    23.47   0.000     13.12939    15.52324
          dexp18 |   14.22159   .6104212    23.30   0.000     13.02487    15.41832
          dexp19 |   4.442653   .6110472     7.27   0.000     3.244701    5.640605
          dexp20 |  -2.040904   .6205621    -3.29   0.001     -3.25751   -.8242982
          dexp21 |   .6050663   .6102633     0.99   0.322    -.5913489    1.801482
          dexp22 |   2.676738   .6114521     4.38   0.000     1.477992    3.875484
          dexp23 |   1.845969   .6213763     2.97   0.003     .6277672    3.064171
          dexp24 |   10.20732   .6119518    16.68   0.000     9.007591    11.40704
          dexp25 |   13.39599   .6105503    21.94   0.000     12.19901    14.59297
          dexp26 |   .6241502   .6103874     1.02   0.307    -.5725083    1.820809
          dexp27 |  -.7422275   .6103943    -1.22   0.224      -1.9389    .4544446
          dexp28 |  -1.635686    .612465    -2.67   0.008    -2.836418   -.4349548
          dexp29 |   4.974551    .623605     7.98   0.000      3.75198    6.197123
          dexp30 |   13.80133   .6102519    22.62   0.000     12.60494    14.99772
          dexp31 |   8.408377   .6281037    13.39   0.000     7.176986    9.639768
          dexp32 |  -1.386433   .6205055    -2.23   0.026    -2.602927   -.1699379
          dexp33 |   13.71171   .6104243    22.46   0.000     12.51498    14.90844
          dexp34 |   2.674934   .6206225     4.31   0.000     1.458209    3.891658
          dexp35 |  -1.739016   .6239791    -2.79   0.005    -2.962321   -.5157109
          dexp36 |  -1.454858   .6235239    -2.33   0.020     -2.67727   -.2324452
          dexp37 |   1.662482   .6243582     2.66   0.008     .4384339     2.88653
          dexp38 |   13.61984   .6102974    22.32   0.000     12.42336    14.81632
          dexp39 |    5.13073   .6111923     8.39   0.000     3.932493    6.328966
          dexp40 |          0  (omitted)
          dexp41 |   13.50532    .617114    21.88   0.000     12.29547    14.71516
          dexp42 |   13.59787   .6104942    22.27   0.000       12.401    14.79474
          dexp43 |   2.070785    .611107     3.39   0.001     .8727162    3.268855
          dexp44 |  -.5465918   .6194238    -0.88   0.378    -1.760966    .6677826
          dexp45 |   1.800519   .6112067     2.95   0.003     .6022548    2.998784
          dexp46 |   15.61918   .6115066    25.54   0.000     14.42033    16.81804
          dexp47 |   16.84393   .6161336    27.34   0.000     15.63601    18.05186
          dexp48 |   3.484983   .6246923     5.58   0.000      2.26028    4.709686
           dimp1 |  -.5169499   .6119338    -0.84   0.398     -1.71664    .6827402
           dimp2 |          0  (omitted)
           dimp3 |  -.9982875   .6261751    -1.59   0.111    -2.225898    .2293226
           dimp4 |  -1.543314   .6246724    -2.47   0.014    -2.767979   -.3186504
           dimp5 |  -2.493593   .6123757    -4.07   0.000    -3.694149   -1.293036
           dimp6 |  -1.488432   .6141977    -2.42   0.015     -2.69256    -.284303
           dimp7 |  -1.744134   .6131087    -2.84   0.004    -2.946127   -.5421401
           dimp8 |  -.8792039   .6117905    -1.44   0.151    -2.078613    .3202052
           dimp9 |  -1.716964   .6132944    -2.80   0.005    -2.919321   -.5146062
          dimp10 |  -1.692138    .613818    -2.76   0.006    -2.895522   -.4887536
          dimp11 |  -1.012701   .6283196    -1.61   0.107    -2.244515    .2191136
          dimp12 |  -.4275758   .6273332    -0.68   0.496    -1.657456    .8023047
          dimp13 |  -2.224384   .6135369    -3.63   0.000    -3.427217   -1.021551
          dimp14 |  -1.841544    .613101    -3.00   0.003    -3.043523   -.6395659
          dimp15 |  -2.867881   .6136935    -4.67   0.000    -4.071021   -1.664741
          dimp16 |  -.4457421   .6229358    -0.72   0.474    -1.667002    .7755174
          dimp17 |  -1.789707   .6249028    -2.86   0.004    -3.014822   -.5645909
          dimp18 |   .4755847   .6262185     0.76   0.448    -.7521106     1.70328
          dimp19 |  -1.084995   .6217852    -1.74   0.081    -2.303999    .1340087
          dimp20 |  -7.395029   .6137786   -12.05   0.000    -8.598335   -6.191722
          dimp21 |  -1.515205   .6270143    -2.42   0.016     -2.74446   -.2859493
          dimp22 |  -2.102666   .6205155    -3.39   0.001     -3.31918    -.886151
          dimp23 |  -.2907965   .6117342    -0.48   0.635    -1.490095    .9085023
          dimp24 |  -1.747562   .6205976    -2.82   0.005    -2.964238   -.5308865
          dimp25 |   .4170185   .6239907     0.67   0.504     -.806309    1.640346
          dimp26 |  -2.229249   .6253329    -3.56   0.000    -3.455209    -1.00329
          dimp27 |  -1.086725   .6252681    -1.74   0.082    -2.312557     .139107
          dimp28 |  -1.845894   .6191436    -2.98   0.003    -3.059718   -.6320687
          dimp29 |  -.7199771   .6123618    -1.18   0.240    -1.920506    .4805522
          dimp30 |  -.8983727   .6278126    -1.43   0.153    -2.129193    .3324477
          dimp31 |  -.9845153    .610235    -1.61   0.107    -2.180875    .2118444
          dimp32 |  -7.489847   .6138138   -12.20   0.000    -8.693223   -6.286472
          dimp33 |  -1.422042   .6250039    -2.28   0.023    -2.647356   -.1967282
          dimp34 |  -2.550239   .6137416    -4.16   0.000    -3.753474   -1.347005
          dimp35 |  -2.119479   .6122393    -3.46   0.001    -3.319768   -.9191894
          dimp36 |  -1.066587   .6123896    -1.74   0.082    -2.267171    .1339966
          dimp37 |  -.5125992   .6105097    -0.84   0.401    -1.709498    .6842991
          dimp38 |  -.6311261   .6263899    -1.01   0.314    -1.859157    .5969051
          dimp39 |  -1.163926    .621138    -1.87   0.061    -2.381661     .053809
          dimp40 |  -1.190264   .6283887    -1.89   0.058    -2.422213    .0416862
          dimp41 |  -.3276512   .6168866    -0.53   0.595    -1.537051     .881749
          dimp42 |  -.3337024   .6243783    -0.53   0.593     -1.55779    .8903851
          dimp43 |  -.7770938   .6234663    -1.25   0.213    -1.999393    .4452057
          dimp44 |  -4.901238   .6123542    -8.00   0.000    -6.101752   -3.700723
          dimp45 |  -.8839441   .6212445    -1.42   0.155    -2.101888    .3339996
          dimp46 |  -.8803774   .6223687    -1.41   0.157    -2.100525    .3397702
          dimp47 |  -.8205589   .6139556    -1.34   0.181    -2.024213     .383095
          dimp48 |  -1.971208   .6120308    -3.22   0.001    -3.171088   -.7713272
           _cons |   8.175194   .9709411     8.42   0.000     6.271674    10.07871
    ------------------------------------------------------------------------------
    
    .
    Can anyone give me an advice on how to fix this?

    With kind regards,
    Ramadan Aly
    Last edited by Ramadan Aly; 19 Jan 2020, 11:18.

  • #2
    I suspect that the problem may be that some o the coefficients are not identified. Please try estimating the model using the ppmlhdfe command.

    Best wishes,

    Joao

    Comment


    • #3
      Good night Joao Santos Silva,

      I used the command that you proposed and I got exactly the same results as without it. here you can see the results:

      Code:
       reghdfe lstreams lgdpconst_imp lgdpconst_exp ldist lpop_tot_imp contig comlang_off colony comcol home internet_imp, a(imp exp)
      (MWFE estimator converged in 2 iterations)
      
      HDFE Linear regression                            Number of obs   =      3,792
      Absorbing 2 HDFE groups                           F(  10,   3687) =      55.15
                                                        Prob > F        =     0.0000
                                                        R-squared       =     0.7177
                                                        Adj R-squared   =     0.7097
                                                        Within R-sq.    =     0.1301
                                                        Root MSE        =     4.1977
      
      -------------------------------------------------------------------------------
           lstreams |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      --------------+----------------------------------------------------------------
      lgdpconst_imp |  -4.779969   7.058094    -0.68   0.498    -18.61812    9.058185
      lgdpconst_exp |    10.2511   6.046126     1.70   0.090     -1.60298    22.10518
              ldist |   -.679207   .1070694    -6.34   0.000    -.8891281    -.469286
       lpop_tot_imp |  -33.36245   17.64555    -1.89   0.059    -67.95846    1.233554
             contig |   .2874681   .3979067     0.72   0.470    -.4926708    1.067607
        comlang_off |   2.555379   .2980925     8.57   0.000     1.970937    3.139822
             colony |   .5296488   .4703669     1.13   0.260    -.3925561    1.451854
             comcol |   1.705284   2.178039     0.78   0.434    -2.564996    5.975564
               home |    5.65193   .6066941     9.32   0.000     4.462441    6.841419
       internet_imp |   1.223391   5.134159     0.24   0.812     -8.84268    11.28946
              _cons |   417.9155   245.5907     1.70   0.089    -63.59156    899.4225
      -------------------------------------------------------------------------------
      
      Absorbed degrees of freedom:
      -----------------------------------------------------+
       Absorbed FE | Categories  - Redundant  = Num. Coefs |
      -------------+---------------------------------------|
               imp |        48           0          48     |
               exp |        48           1          47     |
      -----------------------------------------------------+
      
      .
      end of do-file
      And when using the ppmlhdfe:

      Code:
       ppmlhdfe lstreams lgdpconst_imp lgdpconst_exp ldist lpop_tot_imp contig comlang_off colony comcol home internet_imp, a(imp exp)
      (dropped 316 observations that are either singletons or separated by a fixed effect)
      note: lgdpconst_imp is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-06)
      note: lgdpconst_exp is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-06)
      note: lpop_tot_imp is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-06)
      Iteration 1:   deviance = 1.6523e+04  eps = .         iters = 4    tol = 1.0e-04  min(eta) =  -2.71  P  
      Iteration 2:   deviance = 1.5301e+04  eps = 7.99e-02  iters = 3    tol = 1.0e-04  min(eta) =  -3.90      
      Iteration 3:   deviance = 1.5122e+04  eps = 1.18e-02  iters = 3    tol = 1.0e-04  min(eta) =  -4.74      
      Iteration 4:   deviance = 1.5099e+04  eps = 1.51e-03  iters = 2    tol = 1.0e-04  min(eta) =  -5.22      
      Iteration 5:   deviance = 1.5098e+04  eps = 7.60e-05  iters = 2    tol = 1.0e-04  min(eta) =  -5.38      
      Iteration 6:   deviance = 1.5098e+04  eps = 3.99e-07  iters = 2    tol = 1.0e-05  min(eta) =  -5.39      
      Iteration 7:   deviance = 1.5098e+04  eps = 1.66e-11  iters = 2    tol = 1.0e-06  min(eta) =  -5.39   S  
      Iteration 8:   deviance = 1.5098e+04  eps = 0.00e+00  iters = 2    tol = 1.0e-08  min(eta) =  -5.39   S O
      ------------------------------------------------------------------------------------------------------------
      (legend: p: exact partial-out   s: exact solver   h: step-halving   o: epsilon below tolerance)
      Converged in 8 iterations and 20 HDFE sub-iterations (tol = 1.0e-08)
      
      HDFE PPML regression                              No. of obs      =      3,476
      Absorbing 2 HDFE groups                           Residual df     =      3,378
                                                        Wald chi2(7)    =     327.12
      Deviance             =  15097.76777               Prob > chi2     =     0.0000
      Log pseudolikelihood = -11787.37434               Pseudo R2       =     0.4703
      -------------------------------------------------------------------------------
                    |               Robust
           lstreams |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      --------------+----------------------------------------------------------------
      lgdpconst_imp |          0  (omitted)
      lgdpconst_exp |          0  (omitted)
              ldist |  -.1538445   .0149901   -10.26   0.000    -.1832246   -.1244644
       lpop_tot_imp |          0  (omitted)
             contig |   -.147098   .0429964    -3.42   0.001    -.2313695   -.0628266
        comlang_off |   .3212997    .037539     8.56   0.000     .2477247    .3948747
             colony |   .0686792    .045628     1.51   0.132    -.0207499    .1581084
             comcol |   .9822976   .3262797     3.01   0.003     .3428012    1.621794
               home |   .2493201   .0746599     3.34   0.001     .1029894    .3956509
       internet_imp |   .0562594   .5981433     0.09   0.925     -1.11608    1.228599
              _cons |   3.616983   .4628117     7.82   0.000     2.709889    4.524078
      -------------------------------------------------------------------------------
      
      Absorbed degrees of freedom:
      -----------------------------------------------------+
       Absorbed FE | Categories  - Redundant  = Num. Coefs |
      -------------+---------------------------------------|
               imp |        48           0          48     |
               exp |        44           1          43     |
      -----------------------------------------------------+
      
      .
      end of do-file
      Is it normal to have such big coefficients? besides that i can't use the interactions as stata closes when I do. My issue is to understand if it is normal or not to have such high values in the coefficients.

      With kind regards,
      José

      Comment


      • #4
        Dear Ramadan Aly,

        I do not see any big coefficients in the ppmlhdfe results. Am I missing something?

        Best wishes,

        Joao

        Comment


        • #5
          Good Night,

          Yes, indeed in closer inspection there are no very big coefficients. Thanks for your help! I have another question relating to calculating the contribution to the total variance of each variable. IS there any way to calculate it through Stata??

          With kind regards,
          José

          Comment

          Working...
          X