Announcement

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

  • ppmlhdfe with time and individual fixed effects

    Hello, I am completely new to Stata and would need some help on how to use the ppmlhdfe command.

    I want to use ppmlhdfe to estimate a gravity equation. I have paneldata and want to use fixed effects to capture time-specific and country-specific fixed effects. From what I can understand, I need to absorb the variables I want as fixed effects in my model, however, I am very unsure on how to do that. Is there any guide on how to use ppmlhdfe?

    When I use the command: ppmlhdfe Export ln_BNP_o ln_BNP_d FTA, absorb(i.country_of_destination1#c.year)
    I get accurate results but I am unsure if both the time and country-specific effects are absorbed since one of the guides I've read says that it only absorbs individual slopes.

    I would be super grateful if anyone could even help me a little bit.

    Kind regards, Moa Rittemar
    Last edited by Moa Rittemar; 28 Dec 2022, 10:04.

  • #2
    ppmlhdfe is from SSC (FAQ Advice #12).

    I have paneldata and want to use fixed effects to capture time-specific and country-specific fixed effects. From what I can understand, I need to absorb the variables I want as fixed effects in my model, however, I am very unsure on how to do that.
    Just include these variables separately within -absorb()-.

    Code:
    ppmlhdfe Export ln_BNP_o ln_BNP_d FTA, absorb(country year)

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      ppmlhdfe is from SSC (FAQ Advice #12).



      Just include these variables separately within -absorb()-.

      Code:
      ppmlhdfe Export ln_BNP_o ln_BNP_d FTA, absorb(country year)
      Thank you!

      Comment


      • #4
        Hello, sorry for jumping in.

        I have a similar problem with Moa. I want to estimate a gravity equation to estimate the impact of FTA implementation to trade creation & diversion. I have product-level panel data from 28 countries ranging from 2003-2020. The data consist of pairwise observation between countries in the product-level (HS Code 6 Digit).
        To get the estimation, I want to use the fixed effect to capture the country-time fixed effect and also the bilateral countrypair fixed effect.

        This is a snapshot of my data:

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str3(reporteriso partneriso) int year long commoditycode double tradevalueus float(ln_gdpcaprep ln_gdpcappar ln_poprep ln_poppar ln_dist) byte(fta1 fta2 fta3)
        "AUS" "AUT" 2003 850110       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850120       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850131       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850132       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850133       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850134       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850140       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850151       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850152       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850153       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850161     242 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850162       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850163       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850164       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850211       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850212       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850213       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850220       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850230       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850240       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850300       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850410 1447387 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850421       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850422    2570 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850423       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850431   11952 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850432       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850433       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850434       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850440   20194 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850450       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850490       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850511    6125 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850519       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850520       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850530       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850590       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850611       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850612       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850613       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850619       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850620       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850690       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850710       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850720       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850730       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850740       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850780       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850790  175444 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850810       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850820       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850880       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850890       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850910       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850920       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850930       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850940       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850980       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 850990       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851010       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851020       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851090       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851110       6 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851120     280 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851130     117 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851140       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851150       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851180    1547 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851190       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851210       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851220      77 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851230       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851240       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851290       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851310       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851390    5871 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851410       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851420       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851430       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851440       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851490       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851511      16 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851519       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851521       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851529       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851531       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851539       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851580       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851590       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851610       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851621       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851629    3258 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851631       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851632       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851633       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851640       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851650       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851660       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851671       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        "AUS" "AUT" 2003 851672       0 3.152736 3.468856 9.898244 9.002257 9.676085 0 0 0
        end
        format %ty year
        ------------------ copy up to and including the previous line ------------------


        I've got the result by using the ppmlhdfe using the code below:

        Code:
        ppmlhdfe tradevalueus ln_gdpcaprep ln_gdpcappar ln_poprep ln_poppar ln_dist border language fta1 fta2 fta3, absorb(i.exp##c.year i.imp##c.year i.exp##i.imp) cluster(i.exp##i.imp)
        Here is the result:
        .
        Code:
         ppmlhdfe tradevalueus ln_gdpcaprep ln_gdpcappar ln_poprep ln_poppar ln_dist border language fta1 fta2 fta3, absorb(i.exp##c.year i.imp##c.year i.exp##i.imp) cluster(i.exp##i.imp)
        (dropped 2112 observations that are either singletons or separated by a fixed effect)
        warning: dependent variable takes very low values after standardizing (2.6699e-08)
        note: 3 variables omitted because of collinearity: ln_dist border language
        Iteration 1:   deviance = 8.9249e+13  eps = .         iters = 5    tol = 1.0e-04  min(eta) =  -5.61  P  
        Iteration 2:   deviance = 5.0964e+13  eps = 7.51e-01  iters = 5    tol = 1.0e-04  min(eta) =  -6.79      
        Iteration 3:   deviance = 4.2191e+13  eps = 2.08e-01  iters = 4    tol = 1.0e-04  min(eta) =  -8.07      
        Iteration 4:   deviance = 4.0977e+13  eps = 2.96e-02  iters = 4    tol = 1.0e-04  min(eta) =  -9.46      
        Iteration 5:   deviance = 4.0892e+13  eps = 2.08e-03  iters = 4    tol = 1.0e-04  min(eta) = -11.20      
        Iteration 6:   deviance = 4.0885e+13  eps = 1.67e-04  iters = 4    tol = 1.0e-04  min(eta) = -12.79      
        Iteration 7:   deviance = 4.0883e+13  eps = 3.66e-05  iters = 4    tol = 1.0e-04  min(eta) = -14.28      
        Iteration 8:   deviance = 4.0883e+13  eps = 8.65e-06  iters = 4    tol = 1.0e-05  min(eta) = -15.78      
        Iteration 9:   deviance = 4.0883e+13  eps = 1.99e-06  iters = 3    tol = 1.0e-06  min(eta) = -16.87   S  
        Iteration 10:  deviance = 4.0883e+13  eps = 4.99e-07  iters = 3    tol = 1.0e-06  min(eta) = -17.88   S  
        Iteration 11:  deviance = 4.0883e+13  eps = 1.34e-07  iters = 3    tol = 1.0e-07  min(eta) = -18.88   S  
        Iteration 12:  deviance = 4.0883e+13  eps = 3.87e-08  iters = 2    tol = 1.0e-07  min(eta) = -19.87   S  
        Iteration 13:  deviance = 4.0883e+13  eps = 1.11e-08  iters = 3    tol = 1.0e-08  min(eta) = -20.86   S  
        Iteration 14:  deviance = 4.0883e+13  eps = 3.09e-09  iters = 3    tol = 1.0e-09  min(eta) = -21.84   S O
        ------------------------------------------------------------------------------------------------------------
        (legend: p: exact partial-out   s: exact solver   h: step-halving   o: epsilon below tolerance)
        Converged in 14 iterations and 51 HDFE sub-iterations (tol = 1.0e-08)
        
        HDFE PPML regression                              No. of obs      =    3590400
        Absorbing 3 HDFE groups                           Residual df     =        913
        Statistics robust to heteroskedasticity           Wald chi2(7)    =     199.98
        Deviance             =  4.08827e+13               Prob > chi2     =     0.0000
        Log pseudolikelihood = -2.04414e+13               Pseudo R2       =     0.4365
        
        Number of clusters (exp##imp)=       914
                                     (Std. Err. adjusted for 914 clusters in exp##imp)
        ------------------------------------------------------------------------------
                     |               Robust
        tradevalueus |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        ln_gdpcaprep |   .1425249   .0822161     1.73   0.083    -.0186158    .3036655
        ln_gdpcappar |   .5815739   .0859087     6.77   0.000     .4131959    .7499518
           ln_poprep |   -1.14227   .9571614    -1.19   0.233    -3.018272    .7337318
           ln_poppar |   -.023711   .0073542    -3.22   0.001    -.0381249   -.0092971
             ln_dist |          0  (omitted)
              border |          0  (omitted)
            language |          0  (omitted)
                fta1 |   .1211393   .0669738     1.81   0.070    -.0101269    .2524055
                fta2 |   -.017706    .067865    -0.26   0.794    -.1507189    .1153069
                fta3 |   .1493818   .0408415     3.66   0.000      .069334    .2294296
               _cons |   27.89424   11.21685     2.49   0.013     5.909611    49.87887
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
                 exp |        34           0          34     |
          exp#c.year |        34           0          34    ?|
                 imp |        28           1          27     |
          imp#c.year |        28           0          28    ?|
             exp#imp |       914         914           0    *|
        -----------------------------------------------------+
        ? = number of redundant parameters may be higher
        * = FE nested within cluster; treated as redundant for DoF computation

        The problem is I'm not sure if it is the correct answer since typically the variable related to country-time (such as GDP and population) will be excluded, but in my case, both variables are still giving the result (is that a correct representation?).


        Thank you,
        Ilham
        Last edited by Ilham Muhammad; 24 Jan 2023, 14:31. Reason: too many picture attachements, and

        Comment


        • #5
          i.imp##c.year
          defines importer indicators (i.imp), importer-specific time trends (i.imp#c.year) and a general time trend (c.year).

          typically the variable related to country-time (such as GDP and population) will be excluded
          They would have been excluded if they were collinear with any of the fixed effects. For example, annual GDP for an importer country is invariant over an importer-year combination. But that is not what you have with time-trends. I think you are thinking of a categorical-by-categorical interaction, i.e., interacting year indicators as opposed to time-trends.

          Code:
          i.imp##i.year

          Comment


          • #6
            Hi Mr. Andrew,

            Thank you for the insight, your reply really helps me.

            Based on your reply, I've tried several combinations of FE as per below:

            ,absorb(i.exp#i.year i.imp#i.year i.exp#i.imp)

            ,absorb(i.exp#c.year i.imp#c.year i.exp#i.imp)

            ,absorb(i.exp##c.year i.imp##c.year i.exp#i.imp)


            Each combination has a different result. If my objective is to capture the effect of trends in each country and also the time-invariant aspect of bilateral relation, which is the most appropriate specification to use?

            Thanks,
            Ilham

            Comment


            • #7
              Typically, with trade data you will see

              Code:
              ppmlhdfe ..., absorb(imp#year exp#year imp#exp) cluster(imp#exp)
              But in your case, you ask

              If my objective is to capture the effect of trends in each country and also the time-invariant aspect of bilateral relation, which is the most appropriate specification to use?
              which corresponds to


              Code:
              ppmlhdfe ..., absorb(i.imp#c.year i.exp#c.year imp#exp) cluster(imp#exp)

              Comment


              • #8
                Originally posted by Andrew Musau View Post
                Typically, with trade data you will see

                Code:
                ppmlhdfe ..., absorb(imp#year exp#year imp#exp) cluster(imp#exp)
                But in your case, you ask



                which corresponds to


                Code:
                ppmlhdfe ..., absorb(i.imp#c.year i.exp#c.year imp#exp) cluster(imp#exp)
                Thank you, Mr. Andrew, your suggestion does help me to progress.

                Best regards,
                Ilham

                Comment


                • #9
                  Hello,
                  Thanks for your helpful comments. I am working on a study about the impact of institution quality on bilateral trade among MENA countries. I have only MENA countries in the original and destination observations. I have this code ppmlhdfe t ldist col45 comlang_off contig lgdp_o lgdp_d lpop_o lpop_d fta_wto linqulo linquld, absorb(i.imp#c.year i.exp#c.year imp#exp) cluster(imp#exp)
                  However, I got these results:

                  HDFE PPML regression No. of obs = 13,485

                  Absorbing 3 HDFE groups Residual df = 878

                  Statistics robust to heteroskedasticity Wald chi2(10) = 352.78

                  Deviance = 741772633.3 Prob > chi2 = 0.0000

                  Log pseudolikelihood = -370959484.1 Pseudo R2 = 0.9444




                  Number of clusters (imp#exp)= 879

                  (Std. err. adjusted for 879 clusters in imp#exp)




                  Robust

                  t Coefficient std. err. z P>z [95% conf. interval]




                  ldist .1130914 .519204 0.22 0.828 -.9045298 1.130713

                  col45 0 (omitted)

                  comlang_off .8465815 365.7479 0.00 0.998 -716.0061 717.6993

                  contig -1.227287 447.2448 -0.00 0.998 -877.8111 875.3565

                  lgdp_o .5951616 .1206984 4.93 0.000 .358597 .8317261

                  lgdp_d .7417076 .0944459 7.85 0.000 .556597 .9268182

                  lpop_o -.0014878 .2368235 -0.01 0.995 -.4656533 .4626777

                  lpop_d .063504 .2677218 0.24 0.813 -.4612211 .5882291

                  fta_wto .286897 .1082046 2.65 0.008 .0748199 .4989741

                  linqulo .2195042 .3682029 0.60 0.551 -.5021602 .9411686

                  linquld -.3115027 .1948589 -1.60 0.110 -.6934191 .0704136

                  _cons -12.54079 188.1845 -0.07 0.947 -381.3756 356.294







                  Absorbed degrees of freedom:




                  Absorbed FE Categories - Redundant = Num. Coefs

                  -

                  imp#c.year 31 0 31 ?

                  exp#c.year 31 0 31 ?

                  imp#exp 879 879 0 *




                  ? = number of redundant parameters may be higher

                  * = FE nested within cluster; treated as redundant for DoF computation

                  I am trying to capture the importer and exporter fixed effect. Do my results look OK?
                  Last edited by Abdalla Muktad; 01 Jul 2024, 22:07.

                  Comment


                  • #10
                    Hello,
                    Thanks for your helpful comments. I am working on a study about the impact of institution quality on bilateral trade among MENA countries. I have only MENA countries in the original and destination observations. I have this code
                    ppmlhdfe t ldist col45 comlang_off contig lgdp_o lgdp_d lpop_o lpop_d fta_wto linqulo linquld, absorb(i.imp#c.year i.exp#c.year imp#exp) cluster(imp#exp)
                    However, I got these results:

                    HDFE PPML regression No. of obs = 13,485

                    Absorbing 3 HDFE groups Residual df = 878

                    Statistics robust to heteroskedasticity Wald chi2(10) = 352.78

                    Deviance = 741772633.3 Prob > chi2 = 0.0000

                    Log pseudolikelihood = -370959484.1 Pseudo R2 = 0.9444




                    Number of clusters (imp#exp)= 879

                    (Std. err. adjusted for 879 clusters in imp#exp)




                    Robust

                    t Coefficient std. err. z P>z [95% conf. interval]




                    ldist .1130914 .519204 0.22 0.828 -.9045298 1.130713

                    col45 0 (omitted)

                    comlang_off .8465815 365.7479 0.00 0.998 -716.0061 717.6993

                    contig -1.227287 447.2448 -0.00 0.998 -877.8111 875.3565

                    lgdp_o .5951616 .1206984 4.93 0.000 .358597 .8317261

                    lgdp_d .7417076 .0944459 7.85 0.000 .556597 .9268182

                    lpop_o -.0014878 .2368235 -0.01 0.995 -.4656533 .4626777

                    lpop_d .063504 .2677218 0.24 0.813 -.4612211 .5882291

                    fta_wto .286897 .1082046 2.65 0.008 .0748199 .4989741

                    linqulo .2195042 .3682029 0.60 0.551 -.5021602 .9411686

                    linquld -.3115027 .1948589 -1.60 0.110 -.6934191 .0704136

                    _cons -12.54079 188.1845 -0.07 0.947 -381.3756 356.294







                    Absorbed degrees of freedom:




                    Absorbed FE Categories - Redundant = Num. Coefs

                    -

                    imp#c.year 31 0 31 ?

                    exp#c.year 31 0 31 ?

                    imp#exp 879 879 0 *




                    ? = number of redundant parameters may be higher

                    * = FE nested within cluster; treated as redundant for DoF computation

                    I am trying to capture the importer and exporter fixed effect. Do my results look OK?

                    Comment


                    • #11
                      Originally posted by Abdalla Muktad View Post
                      I am trying to capture the importer and exporter fixed effect.
                      The absorbed interaction imp#exp should do it as far as capturing importer-exporter pair fixed effects.

                      Do my results look OK?
                      To answer this, I'd need to know your model and the underlying theory. You should check out past studies and first confirm that your specification is correct and that the results align with theirs. However, as long as your specification is correct and there are no data problems, you may not get the same results. Finding something new or different is an integral part of research, as is confirming previous results.

                      Comment


                      • #12
                        Dear Statalisters,

                        I just wanted to ask about the "ppmlhdfe" command. I am currently doing my thesis on FDI inflows (and exchange rate volatilities), and I wanted to know how to create time invariant country and country-pair fixed effects, as well as time fixed effects. The variables in my model are the volatility of the real effective exchange rate (VREER), the real effective exchange rate (REER) and the GDPs and GDP per capitas of the origin and destination countries. The countries are sorted by iso numbers/codes by origin and destination. Here is my example code:

                        Code:
                        egen pair_id = group(isonum_o isonum_d)
                        Code:
                        xtset pair_id year
                        Code:
                        ppmlhdfe FDIflow lnvreer lnreer lngdp_o lngdp_d lngdpcap_o lngdpcap_d, absorb(isonum_o isonum_d pair_id year) cluster(pair_id)
                        Click image for larger version

Name:	Fixed Effects Model.png
Views:	3
Size:	380.5 KB
ID:	1759207
                        When I run this code, the sign for REER does not conform to what the literature suggests (REER should be negative). However, when I remove fixed effects and include time invariant characteristics such as colonial dependence, common languages and contiguity, the regression results look more similar to the literature:

                        Code:
                        ppmlhdfe FDIflow lnvreer lnreer lngdp_o lngdp_d lngdpcap_o lngdpcap_d lndist contig comlang_off col_dep_ever, cluster(pair_id)
                        Click image for larger version

Name:	Classic Model.png
Views:	2
Size:	452.2 KB
ID:	1759208

                        My r-squared significantly decreases too. Would you have any advice or suggestions? Perhaps I have coded my fixed effects wrong.

                        Kind regards,

                        Ronan
                        Attached Files

                        Comment


                        • #13
                          see https://www.statalist.org/forums/for...15#post1759215

                          Comment

                          Working...
                          X