Announcement

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

  • After an estimation with fixed effects, my e(b) matrix dmension change from a computer to another

    Hi,

    After an estimation with fixed effect (with OLS or PPML) such as "ppml v dist contig tariff FE_it* FE_jt*", we noticed with my supervisor that the matrix of coefficient e(b) didn't have the same dimension when I executed the code on my computer or when she did it. In her case, coefficient corresponding to omitted FE are present in the matrix and equal to zero. In my case, these coefficient don't appear in the matrix. Therefore, our matrices e(b) don't have the same size, and it's problematic for what I want to do next.

    We have exactly the same version of STATA (15.1). Would you know where can the difference come from ? Maybe parameters ? And how to switch from one situation to another ?

    Thanks a lot, hope it's clear enough.

    Lucile

  • #2
    You can also check revision number with command -about-, and since -ppml- is an external command, you will have to check its version too. Note that the version on SSC is newer that the one in Stata Journal archives.

    I you have doubts, check your installation with IQT and reinstall packages from scratch.

    Comment


    • #3
      After an estimation with fixed effect (with OLS or PPML) such as "ppml v dist contig tariff FE_it* FE_jt*", we noticed with my supervisor that the matrix of coefficient e(b) didn't have the same dimension when I executed the code on my computer or when she did it. In her case, coefficient corresponding to omitted FE are present in the matrix and equal to zero. In my case, these coefficient don't appear in the matrix. Therefore, our matrices e(b) don't have the same size, and it's problematic for what I want to do next.
      The default behavior with factor variables (as far as I know) is to include the base category in e(b), with its coefficient value equal to 0. Moving from your situation to that of your supervisor is straightforward, just explicitly define the base category in your regression, e.g., 1.var in the example below

      Code:
      regress depvar ind.vars  ib1.var
      The opposite is more challenging but can be done. Here is an example:

      Code:
      webuse grunfeld
      quietly regress invest mvalue i.company
      mat list e(b)
      Here, the base category is included in e(b)

      Code:
      e(b)[1,12]
                              1b.          2.          3.          4.          5.          6.          7.          8.          9.
              mvalue     company     company     company     company     company     company     company     company     company
      y1   .18987756           0   250.94958  -51.444149   169.37838   232.73144   190.56796   234.03364   130.38064   193.41625
      
                  10.            
             company       _cons
      y1   204.49809   -214.8799
      To exclude it, we need to explicitly specify all the categories except the base (i.e., 2.company to 10.company). In this case, because the numbers are consecutive, we can easily do this in a loop and store them in a local macro.

      Code:
      forval i=2/10{
      local fvars "`fvars' `i'.company"
      }
      di "`fvars'"
      The above results in the list:

      Code:
      . di "`fvars'"
       2.company 3.company 4.company 5.company 6.company 7.company 8.company 9.company 10.company
      Finally, run the regression adding Xbn.var, where X is the first variable in your list, as below

      Code:
      quietly regress invest mvalue 2bn.company `fvars'
      mat list e(b)
      and the resulting matrix e(b) will not have the base category


      Code:
      . mat list e(b)
      
      e(b)[1,11]
                               2.          3.          4.          5.          6.          7.          8.          9.         10.
              mvalue     company     company     company     company     company     company     company     company     company
      y1   .18987756   250.94958  -51.444149   169.37838   232.73144   190.56796   234.03364   130.38064   193.41625   204.49809
      
                    
               _cons
      y1   -214.8799

      Comment


      • #4
        Thank you for your answers but I don't think the base category is the issue here. It's not only the base which is omitted but also other fixed effects. for example, I can have:
        "note: itit_133 omitted because of collinearity
        note: jtjt_31 omitted because of collinearity
        note: jtjt_63 omitted because of collinearity
        note: jtjt_184 omitted because of collinearity"
        So changing the base won't impact the other omitted fixed effects I guess. I really need to include the coefficients (which are 0) of the omitted fixed effects in my e(b) matrix, which is not the case at the present time.

        Comment


        • #5
          What are you hoping to do with these dummy variable coefficients? The fixed effects are just nuisance parameters. Also, it appears that you generated the dummy variables manually. Is there any reason why you are not using factor variables?
          Last edited by Andrew Musau; 19 Feb 2019, 04:08.

          Comment


          • #6
            Well I need the whole e(b) matrix if I want to use gravity. More precisely, I aim to use a general equilibrium with structural gravity (From the Advanced Guide to trade Policy Analysis, Yotov Pieermatini, Monteiro and Larch, 2016). In a first step I need all the coefficient (even the zero ones) to predict intra-national trade flows based on my gravity estimates from international trade flows only.

            Comment


            • #7
              That literature is unfamiliar to me. In any case, you can omit the categories yourself instead of letting Stata do it. Place an o. in front of the omitted variable.

              Code:
              webuse grunfeld
              qui tab company, gen(company)
              quietly regress invest mvalue company1 company2 o.company3 o.company4 company5 company6 o.company7
              mat list e(b)
              Code:
              . mat list e(b)
              
              e(b)[1,9]
                                                               o.          o.                                  o.            
                      mvalue    company1    company2    company3    company4    company5    company6    company7       _cons
              y1   .09094443    218.4066   235.67415           0           0   45.277234   21.752258           0  -4.5256398

              Comment

              Working...
              X