Announcement

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

  • ppml and ppmlhdfe in gravity model

    Dear Joao Santos Silva

    I am an undergraduate student who is researching for his thesis about the trade impact of non-tariff measures on Peruvian exports in 2016. For this purpose, and since I have a large number of zeros in my sample, I'm using the gravity model and PPML estimator as you recommend on your papers titled " The log of gravity" (2006) and "Further simulation evidence on the performance of the Poisson pseudo-maximum likelihood estimation" (2011). Also, I'm using the UNESCAP (2013) user guide in order to get the correct code to estimate my model using the PPML. However, I still have some questions about your estimator and its results.

    1) My dataset contains 50 importer fixed-effects and 21 HS sector fixed-effects. Is it correct to include very high fixed effects into PPML estimations? Do I have to use the ppmlhdfe estimator? Is it any difference between ppml with high fixed effects and ppmlhdfe estimator?

    2) The outcome table (after 11 iterations) presents a warning message which says that I need to rescale the lnPIB_reporter variable (which is in million of dollars). Does it have any consequence if I don't rescale the above variable?

    3) Is it neccessary to turn on the "option strict"?

    Finally, I was wondering if you can share me the stata code of your 2011 paper to observe how to estimate the ET Tobit and GPML estimator. I want to use them in my robustness check.

    Best,

    Juan Quicana

    Pd: I attach my stata code

    Code:
    ppml exports lnPBI_partner lnPBI_reporter lnDistancia frontera lenguaje colonia ALC mediterraneo ln_arancel MNA_dummy exp_dum_* imp_dum_* seccion_dum_*, cluster(distancia)

  • #2
    Dear Juan Quicana,

    1) You can use either ppml or ppmlhdfe; the results should be the same but ppmlhdfe is much faster.

    2) You can ignore the warning if you get convergence, but rescaling the variables may help with convergence.

    3) I am afraid I did not use Stata for that.

    Best of luck,

    Joao

    Comment


    • #3
      Dear Joao Santos Silva ,

      I have problems with ppml estimation. When I applied the RESET test for robustness check with OLS estimations, the Null Hypothesis is not rejected which is a mistake because, as Santos Silva & Tenreyro (2006) shows, only the PPML estimation should not reject this one. My data is about the Peruvian exports (only one exporter) to its 50 major trade partners (i.e. 50 importers). So, lnExportaciones is the log of Peruvian exports in 2016, lnDistancia is the log of distance between Peru and its partners, frontera is a dummy for common borders, colonia is a dummy for colonial tie, ALC is a dummy for the existence of any Free Trade Agreement, ln_arancel is the log of (1+NMF tariff), MNA_dummy is a dummy for the presence of any technical non-tariff measure at hs6 product, and the remain variables are fixed effects for exporter, importer and HS sector.

      I attach my results using OLS and PPML estimations on augmented gravity model.

      This is the outcome using OLS estimations and RESET test using its results.

      Code:
       reg lnExportaciones lnDistancia frontera lenguaje colonia ALC mediterraneo ln_arancel MNA_dummy exp_dum_* imp_dum_* seccion_dum_*, ro
      > bust cluster(distancia)
      note: lenguaje omitted because of collinearity
      note: exp_dum_1 omitted because of collinearity
      note: imp_dum_5 omitted because of collinearity
      note: imp_dum_6 omitted because of collinearity
      note: imp_dum_7 omitted because of collinearity
      note: imp_dum_9 omitted because of collinearity
      note: imp_dum_25 omitted because of collinearity
      note: imp_dum_39 omitted because of collinearity
      note: seccion_dum_15 omitted because of collinearity
      
      Linear regression Number of obs = 22,968
      F(21, 49) = .
      Prob > F = .
      R-squared = 0.1083
      Root MSE = 3.1238
      
      (Std. Err. adjusted for 50 clusters in distancia)
      --------------------------------------------------------------------------------
      | Robust
      lnExportacio~s | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      ---------------+----------------------------------------------------------------
      lnDistancia | -.2998416 .0685826 -4.37 0.000 -.4376635 -.1620197
      frontera | .6653672 .1170468 5.68 0.000 .4301529 .9005815
      lenguaje | 0 (omitted)
      colonia | 2.121283 .0539995 39.28 0.000 2.012767 2.229799
      ALC | 1.440475 .0598281 24.08 0.000 1.320246 1.560704
      mediterraneo | -1.996203 .0786285 -25.39 0.000 -2.154212 -1.838193
      ln_arancel | -.0855022 .043193 -1.98 0.053 -.1723018 .0012975
      MNA_dummy | .0311182 .1154152 0.27 0.789 -.2008173 .2630536
      exp_dum_1 | 0 (omitted)
      imp_dum_1 | .6857985 .0435804 15.74 0.000 .5982204 .7733766
      imp_dum_2 | -1.615787 .1637222 -9.87 0.000 -1.944799 -1.286775
      imp_dum_3 | 1.043826 .0463143 22.54 0.000 .9507542 1.136898
      imp_dum_4 | .2572804 .0682895 3.77 0.000 .1200474 .3945133
      imp_dum_5 | 0 (omitted)
      imp_dum_6 | 0 (omitted)
      imp_dum_7 | 0 (omitted)
      imp_dum_8 | -.659314 .0683305 -9.65 0.000 -.7966293 -.5219986
      imp_dum_9 | 0 (omitted)
      imp_dum_10 | -2.074721 .0758223 -27.36 0.000 -2.227092 -1.92235
      imp_dum_11 | 1.419923 .0729906 19.45 0.000 1.273243 1.566603
      imp_dum_12 | -2.10325 .1012643 -20.77 0.000 -2.306749 -1.899752
      imp_dum_13 | -2.478621 .091669 -27.04 0.000 -2.662837 -2.294405
      imp_dum_14 | -.127389 .0653746 -1.95 0.057 -.2587642 .0039862
      imp_dum_15 | .0927774 .0639727 1.45 0.153 -.0357806 .2213353
      imp_dum_16 | -.5920855 .0589754 -10.04 0.000 -.710601 -.4735701
      imp_dum_17 | -1.848416 .0980064 -18.86 0.000 -2.045368 -1.651465
      imp_dum_18 | -2.307547 .094996 -24.29 0.000 -2.498448 -2.116645
      imp_dum_19 | -1.446503 .0709078 -20.40 0.000 -1.588997 -1.304008
      imp_dum_20 | -.8376343 .0534267 -15.68 0.000 -.9449993 -.7302693
      imp_dum_21 | .1184033 .0528089 2.24 0.030 .0122799 .2245267
      imp_dum_22 | -.7777943 .0674378 -11.53 0.000 -.9133156 -.6422731
      imp_dum_23 | 1.969916 .0995804 19.78 0.000 1.769802 2.170031
      imp_dum_24 | -.9649846 .0676121 -14.27 0.000 -1.100856 -.8291129
      imp_dum_25 | 0 (omitted)
      imp_dum_26 | 1.961194 .0752227 26.07 0.000 1.810028 2.112359
      imp_dum_27 | 2.315353 .0947973 24.42 0.000 2.124851 2.505855
      imp_dum_28 | -.0137991 .0524735 -0.26 0.794 -.1192486 .0916504
      imp_dum_29 | -.3083044 .0402962 -7.65 0.000 -.3892826 -.2273262
      imp_dum_30 | .6142792 .066835 9.19 0.000 .4799692 .7485892
      imp_dum_31 | -1.346248 .0815976 -16.50 0.000 -1.510225 -1.182272
      imp_dum_32 | 1.30673 .082259 15.89 0.000 1.141424 1.472035
      imp_dum_33 | 7.536008 .2247036 33.54 0.000 7.08445 7.987567
      imp_dum_34 | -1.113641 .0923868 -12.05 0.000 -1.299299 -.927983
      imp_dum_35 | -.0711428 .0618066 -1.15 0.255 -.1953478 .0530622
      imp_dum_36 | -.4017771 .0925707 -4.34 0.000 -.5878049 -.2157494
      imp_dum_37 | 1.337569 .0606326 22.06 0.000 1.215723 1.459415
      imp_dum_38 | -2.224083 .1017227 -21.86 0.000 -2.428502 -2.019663
      imp_dum_39 | 0 (omitted)
      imp_dum_40 | 2.123605 .0233982 90.76 0.000 2.076585 2.170626
      imp_dum_41 | -.7301875 .0789125 -9.25 0.000 -.888768 -.571607
      imp_dum_42 | -1.345195 .065103 -20.66 0.000 -1.476025 -1.214366
      imp_dum_43 | -.8963577 .0734018 -12.21 0.000 -1.043864 -.7488513
      imp_dum_44 | .8043817 .0740803 10.86 0.000 .6555118 .9532517
      imp_dum_45 | 1.121185 .0400836 27.97 0.000 1.040634 1.201736
      imp_dum_46 | -2.700035 .1230584 -21.94 0.000 -2.94733 -2.45274
      imp_dum_47 | 1.082689 .0567908 19.06 0.000 .9685633 1.196814
      imp_dum_48 | -1.841087 .0966188 -19.06 0.000 -2.035249 -1.646924
      imp_dum_49 | 3.217984 .0720305 44.68 0.000 3.073233 3.362734
      imp_dum_50 | 1.728445 .0854262 20.23 0.000 1.556775 1.900115
      seccion_dum_1 | .6094123 .9347438 0.65 0.517 -1.269026 2.48785
      seccion_dum_2 | .5144564 .8542967 0.60 0.550 -1.202317 2.23123
      seccion_dum_3 | .7990357 .9916706 0.81 0.424 -1.193801 2.791873
      seccion_dum_4 | .5795956 .8440886 0.69 0.496 -1.116664 2.275855
      seccion_dum_5 | -1.204721 .8828119 -1.36 0.179 -2.978798 .569356
      seccion_dum_6 | .9570452 .9967685 0.96 0.342 -1.046036 2.960126
      seccion_dum_7 | -.5086988 .8826663 -0.58 0.567 -2.282483 1.265085
      seccion_dum_8 | -1.020494 .8730824 -1.17 0.248 -2.775018 .7340312
      seccion_dum_9 | -1.436218 .7945794 -1.81 0.077 -3.032985 .1605495
      seccion_dum_10 | -2.331401 .9006834 -2.59 0.013 -4.141392 -.5214097
      seccion_dum_11 | -1.002241 .8314073 -1.21 0.234 -2.673016 .6685346
      seccion_dum_12 | -1.703868 .8221108 -2.07 0.043 -3.355961 -.0517743
      seccion_dum_13 | -1.59006 .8393409 -1.89 0.064 -3.276779 .0966586
      seccion_dum_14 | .0822513 .7290053 0.11 0.911 -1.38274 1.547242
      seccion_dum_15 | 0 (omitted)
      seccion_dum_16 | -1.538568 .8492565 -1.81 0.076 -3.245212 .1680773
      seccion_dum_17 | -1.754125 .7792247 -2.25 0.029 -3.320036 -.1882145
      seccion_dum_18 | -1.153806 .7881399 -1.46 0.150 -2.737632 .4300206
      seccion_dum_19 | -2.248167 .7731533 -2.91 0.005 -3.801876 -.694457
      seccion_dum_20 | -1.666725 .8304987 -2.01 0.050 -3.335674 .0022248
      seccion_dum_21 | -1.14414 .9493878 -1.21 0.234 -3.052006 .7637259
      _cons | -3.025892 .9701796 -3.12 0.003 -4.975541 -1.076243
      --------------------------------------------------------------------------------
      
      .
      end of do-file
      
      
      . predict fit, xb
      (8,855 missing values generated)
      
      . gen fit2=fit^2
      (8,855 missing values generated)
      
      . qui reg lnExportaciones lnDistancia frontera lenguaje colonia ALC mediterraneo ln_arancel MNA_dummy fit2 exp_dum_* imp_dum_* seccion_
      > dum_*, robust cluster(distancia)
      
      . test fit2=0
      
      ( 1) fit2 = 0
      
      F( 1, 49) = 4.10
      Prob > F = 0.0484
      And this one is using the PPML estimator and its RESET Test.

      Code:
      ppml exports lnDistancia frontera lenguaje colonia ALC mediterraneo ln_arancel MNA_dummy exp_dum_* imp_dum_* seccion_dum_*, cluster(d
      > istancia) nocons
      
      note: checking the existence of the estimates
      
      Number of regressors excluded to ensure that the estimates exist: 1
      Excluded regressors: exp_dum_1
      Number of observations excluded: 0
      
      note: lenguaje omitted because of collinearity
      note: imp_dum_2 omitted because of collinearity
      note: imp_dum_6 omitted because of collinearity
      note: imp_dum_7 omitted because of collinearity
      note: imp_dum_9 omitted because of collinearity
      note: imp_dum_39 omitted because of collinearity
      note: seccion_dum_21 omitted because of collinearity
      
      note: starting ppml estimation
      note: exports has noninteger values
      
      Iteration 1: deviance = 4593500
      Iteration 2: deviance = 1780699
      Iteration 3: deviance = 784224.2
      Iteration 4: deviance = 448619.8
      Iteration 5: deviance = 345239.1
      Iteration 6: deviance = 317970.5
      Iteration 7: deviance = 313196.8
      Iteration 8: deviance = 312894.9
      Iteration 9: deviance = 312892.9
      Iteration 10: deviance = 312892.9
      Iteration 11: deviance = 312892.9
      
      Number of parameters: 72
      Number of observations: 251391
      Pseudo log-likelihood: -161567.16
      R-squared: .01332209
      Option strict is: off
      (Std. Err. adjusted for 50 clusters in distancia)
      --------------------------------------------------------------------------------
      | Robust
      exports | Coef. Std. Err. z P>|z| [95% Conf. Interval]
      ---------------+----------------------------------------------------------------
      lnDistancia | -.4314336 .0913318 -4.72 0.000 -.6104405 -.2524266
      frontera | .0536002 .4740994 0.11 0.910 -.8756175 .982818
      colonia | -2.148252 .5473999 -3.92 0.000 -3.221136 -1.075368
      ALC | -.6642191 .21579 -3.08 0.002 -1.08716 -.2412786
      mediterraneo | 1.386913 .2031351 6.83 0.000 .9887759 1.785051
      ln_arancel | -.5273742 .4726209 -1.12 0.264 -1.453694 .3989458
      MNA_dummy | .327095 .5174765 0.63 0.527 -.6871404 1.34133
      imp_dum_1 | -1.114786 .7385051 -1.51 0.131 -2.562229 .3326577
      imp_dum_3 | -2.287402 .1831118 -12.49 0.000 -2.646294 -1.928509
      imp_dum_4 | -.7043209 .0894402 -7.87 0.000 -.8796204 -.5290213
      imp_dum_5 | -1.966358 .0901732 -21.81 0.000 -2.143094 -1.789621
      imp_dum_8 | -.1922745 .2714673 -0.71 0.479 -.7243406 .3397917
      imp_dum_10 | 2.030261 .2649003 7.66 0.000 1.511066 2.549456
      imp_dum_11 | 2.589501 .48576 5.33 0.000 1.637428 3.541573
      imp_dum_12 | .8760401 1.019772 0.86 0.390 -1.122677 2.874757
      imp_dum_13 | -1.116519 .2784217 -4.01 0.000 -1.662215 -.5708223
      imp_dum_14 | -.3284742 .0896567 -3.66 0.000 -.5041981 -.1527503
      imp_dum_15 | -2.638665 .0896506 -29.43 0.000 -2.814377 -2.462953
      imp_dum_16 | -1.240777 .2715198 -4.57 0.000 -1.772946 -.7086077
      imp_dum_17 | .7759496 .9283841 0.84 0.403 -1.04365 2.595549
      imp_dum_18 | 2.059247 .5389441 3.82 0.000 1.002936 3.115558
      imp_dum_19 | -2.749813 .0902551 -30.47 0.000 -2.92671 -2.572917
      imp_dum_20 | -1.674184 .0894419 -18.72 0.000 -1.849487 -1.498881
      imp_dum_21 | -.7085908 .0894534 -7.92 0.000 -.8839162 -.5332653
      imp_dum_22 | -1.69295 .2719001 -6.23 0.000 -2.225865 -1.160036
      imp_dum_23 | -2.964382 .2365645 -12.53 0.000 -3.42804 -2.500724
      imp_dum_24 | -2.105445 .2730055 -7.71 0.000 -2.640526 -1.570364
      imp_dum_25 | -3.820418 .6337192 -6.03 0.000 -5.062484 -2.578351
      imp_dum_26 | -3.283073 .7815935 -4.20 0.000 -4.814968 -1.751178
      imp_dum_27 | .208122 1.181887 0.18 0.860 -2.108334 2.524578
      imp_dum_28 | -1.003474 .0895397 -11.21 0.000 -1.178969 -.8279792
      imp_dum_29 | .1850982 .1439038 1.29 0.198 -.0969482 .4671445
      imp_dum_30 | .7520112 .4614294 1.63 0.103 -.1523739 1.656396
      imp_dum_31 | .9273767 .4205746 2.21 0.027 .1030656 1.751688
      imp_dum_32 | -2.878425 .3426314 -8.40 0.000 -3.54997 -2.20688
      imp_dum_33 | -3.682623 .5347607 -6.89 0.000 -4.730735 -2.634511
      imp_dum_34 | -2.57902 .2934571 -8.79 0.000 -3.154186 -2.003855
      imp_dum_35 | -.3156104 .0894486 -3.53 0.000 -.4909264 -.1402944
      imp_dum_36 | -3.769253 .2506863 -15.04 0.000 -4.260589 -3.277917
      imp_dum_37 | -4.74559 .2039107 -23.27 0.000 -5.145248 -4.345932
      imp_dum_38 | 1.193222 .1915438 6.23 0.000 .8178035 1.568641
      imp_dum_40 | -2.579854 .7342528 -3.51 0.000 -4.018963 -1.140745
      imp_dum_41 | -3.460296 .0948384 -36.49 0.000 -3.646176 -3.274416
      imp_dum_42 | -2.019692 .2721201 -7.42 0.000 -2.553038 -1.486346
      imp_dum_43 | -3.035312 .0898989 -33.76 0.000 -3.21151 -2.859113
      imp_dum_44 | -2.977139 .1058087 -28.14 0.000 -3.18452 -2.769758
      imp_dum_45 | -4.105837 .3306784 -12.42 0.000 -4.753955 -3.457719
      imp_dum_46 | -1.394045 .0322961 -43.16 0.000 -1.457345 -1.330746
      imp_dum_47 | 1.218534 .2017521 6.04 0.000 .8231075 1.613961
      imp_dum_48 | -.4187494 .132765 -3.15 0.002 -.6789641 -.1585348
      imp_dum_49 | -2.626287 .5964335 -4.40 0.000 -3.795275 -1.457299
      imp_dum_50 | -2.920057 .5411621 -5.40 0.000 -3.980715 -1.859399
      seccion_dum_1 | 2.454451 .5466919 4.49 0.000 1.382954 3.525947
      seccion_dum_2 | 4.030944 .5201629 7.75 0.000 3.011444 5.050444
      seccion_dum_3 | 3.471219 .7475501 4.64 0.000 2.006047 4.93639
      seccion_dum_4 | 4.332082 .9034854 4.79 0.000 2.561284 6.102881
      seccion_dum_5 | 1.653574 .69767 2.37 0.018 .2861657 3.020982
      seccion_dum_6 | 5.801144 .7624295 7.61 0.000 4.306809 7.295478
      seccion_dum_7 | 1.339814 .7187279 1.86 0.062 -.0688673 2.748494
      seccion_dum_8 | 2.553449 .8186998 3.12 0.002 .9488271 4.158071
      seccion_dum_9 | 1.397105 .8936823 1.56 0.118 -.3544798 3.14869
      seccion_dum_10 | 1.251831 .753649 1.66 0.097 -.2252937 2.728956
      seccion_dum_11 | 2.309953 .6252397 3.69 0.000 1.084506 3.535401
      seccion_dum_12 | 1.270458 .9277279 1.37 0.171 -.5478556 3.088771
      seccion_dum_13 | 2.330507 .7416038 3.14 0.002 .8769899 3.784023
      seccion_dum_14 | 6.331289 .7285506 8.69 0.000 4.903356 7.759222
      seccion_dum_15 | 1.002838 .614894 1.63 0.103 -.2023323 2.208008
      seccion_dum_16 | 3.172186 .7711696 4.11 0.000 1.660721 4.68365
      seccion_dum_17 | .5115352 .5719157 0.89 0.371 -.6093991 1.632469
      seccion_dum_18 | .8632077 .7256116 1.19 0.234 -.5589649 2.28538
      seccion_dum_19 | -.8254245 .549203 -1.50 0.133 -1.901843 .2509937
      seccion_dum_20 | 1.710909 .7958455 2.15 0.032 .1510808 3.270738
      --------------------------------------------------------------------------------
      
      predict fitt, xb
      (8,855 missing values generated)
      
      . gen fitt2=fitt^2
      (8,855 missing values generated)
      
      . qui ppml exports lnDistancia frontera lenguaje colonia ALC mediterraneo ln_arancel MNA_dummy fitt2 exp_dum_* imp_dum_* seccion_dum_*,
      > cluster(distancia) nocons
      WARNING: fitt2 has very large values, consider rescaling or recentering
      Number of regressors excluded to ensure that the estimates exist: 1
      Number of observations excluded: 0
      
      . test fitt2=0
      
      ( 1) fitt2 = 0
      
      chi2( 1) = 4.94
      Prob > chi2 = 0.0263
      Is there any problem with my code? Is it any problem with my model specification?

      I'll be waiting for your reply.

      Comment


      • #4
        Dear Juan Quicana,

        I think you may have misread our paper. Whatever the results of the test, OLS should not be used in this context.

        Best wishes,

        Joao

        Comment


        • #5
          Dear Joao Santos Silva

          Thanks for your reply.
          I have other questions about ppml. If my R2 is too small, am I making a mistake? is my model misspecified?. Furthermore, if the RESET test fail to check the PPML regression, is my model misspecified? I read your comment in other forum that if my data is only about one exporter country to the rest of the world (which is my case), the RESET could fail. Can you explain me that affirmation?

          Gratefully,

          Juan

          Comment


          • #6
            Dear Juan Quicana,

            The R2 is meaningless, so a low R2 is not an issue in itself. Having said that, gravity equations typically have high R2 values, so a low value may indicate that there is something wrong with what you are doing, or something strange about your data.

            In my experience, gravity equations fit very well when we use data for a large number of countries, but often fit poorly (and fail the RESET) when using data for a small number of countries. This suggests that the standard gravity equation does a good job describing world-wide trade flows, but may struggle to describe trade between a particular set of countries, which is not surprising.

            Best wishes,

            Joao

            Comment


            • #7
              Dear Joao Santos Silva

              I have a last question about RESET test. If I use the ppmlhdfe estimator, may I use the RESET test?

              Gratefully,
              Juan

              Comment


              • #8
                Sure! By the way, ppmlhdfe is not an estimator but a command that implements the PPML estimator.

                Comment

                Working...
                X