Announcement

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

  • Margins 'not estimable' using Fixed Effects

    Hi all,

    I am running a regression in the context online shopping with the price on the number of competitors (n_comp) and the number of algorithmic competitors (n_algo) per product (and some other covariates). I am using fixed effects on the product level (bbox_prod_id).

    I run the below regression. I am interested in the interactions; I want to know how to the price inreases when holding the number of competitors constant when out of those the number of algorithmic sellers increases; hence: n_comp ## n_algo20. I use

    Code:
    ssc install reghdfe
    to run a fixed effects linear regression. The regular post-regression margins command apply to this package.

    Code:
    reghdfe bbox_price rating deliverytime ib1.n_comp##ib0.n_algo20, vce(robust) absorb(i.bbox_prod_id)
    I get the following output. In the main effect the dummy on algo = 3 is ommitted. Some of the interactions terms are empty as there are no observations.

    Code:
    HDFE Linear regression                            Number of obs   =  2,461,755
    Absorbing 1 HDFE group                            F(  30,2459633) =     724.32
                                                      Prob > F        =     0.0000
                                                      R-squared       =     0.9987
                                                      Adj R-squared   =     0.9987
                                                      Within R-sq.    =     0.0110
                                                      Root MSE        =     8.1160
    
    ---------------------------------------------------------------------------------
                    |               Robust
         bbox_price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
             rating |   .0669766    .016844     3.98   0.000      .033963    .0999903
       deliverytime |   .0301215   .0028871    10.43   0.000     .0244628    .0357802
                    |
             n_comp |
                 2  |  -8.697992   .5367493   -16.20   0.000    -9.750002   -7.645982
                 3  |  -9.906928   .5329557   -18.59   0.000     -10.9515   -8.862353
                 4  |  -12.66134   .5337393   -23.72   0.000    -13.70745   -11.61523
                 5  |  -13.27949   .5358449   -24.78   0.000    -14.32973   -12.22925
                 6  |  -13.82984   .5354704   -25.83   0.000    -14.87934   -12.78034
                 7  |  -14.14701   .5342757   -26.48   0.000    -15.19417   -13.09985
                 8  |  -13.86282   .5336693   -25.98   0.000    -14.90879   -12.81684
                 9  |  -13.89057    .533477   -26.04   0.000    -14.93617   -12.84498
                10  |  -14.67815   .5332516   -27.53   0.000    -15.72331     -13.633
                    |
           n_algo20 |
                 1  |  -5.244431   .5690095    -9.22   0.000     -6.35967   -4.129192
                 2  |    .535371   .0689879     7.76   0.000     .4001572    .6705849
                 3  |          0  (omitted)
                    |
    n_comp#n_algo20 |
               1 2  |          0  (empty)
               1 3  |          0  (empty)
               2 1  |   7.540803   .5746086    13.12   0.000      6.41459    8.667016
               2 2  |          0  (empty)
               2 3  |          0  (empty)
               3 1  |   6.097393   .5701206    10.69   0.000     4.979976    7.214809
               3 2  |  -3.511021   .1565072   -22.43   0.000     -3.81777   -3.204273
               3 3  |          0  (empty)
               4 1  |   6.887074    .568199    12.12   0.000     5.773423    8.000724
               4 2  |   3.785494    .115617    32.74   0.000     3.558888    4.012099
               4 3  |          0  (empty)
               5 1  |   7.991913   .5708438    14.00   0.000     6.873079    9.110747
               5 2  |   2.884401   .0997314    28.92   0.000     2.688931    3.079872
               5 3  |          0  (empty)
               6 1  |    5.56643   .5699694     9.77   0.000      4.44931    6.683551
               6 2  |   1.858377   .0829974    22.39   0.000     1.695705    2.021049
               6 3  |          0  (empty)
               7 1  |   6.180863   .5700949    10.84   0.000     5.063497    7.298229
               7 2  |   1.392782   .0746451    18.66   0.000      1.24648    1.539083
               7 3  |          0  (empty)
               8 1  |   5.323021   .5719871     9.31   0.000     4.201946    6.444096
               8 2  |   .7164914   .0739854     9.68   0.000     .5714826    .8615002
               8 3  |          0  (empty)
               9 1  |   5.287586   .5728889     9.23   0.000     4.164744    6.410429
               9 2  |  -.4005877   .0574081    -6.98   0.000    -.5131056   -.2880697
               9 3  |   2.381554   .0584047    40.78   0.000     2.267083    2.496025
              10 1  |   6.379034   .5722008    11.15   0.000      5.25754    7.500527
              10 2  |          0  (omitted)
              10 3  |          0  (omitted)
                    |
              _cons |   69.77762    .560874   124.41   0.000     68.67832    70.87691
    ---------------------------------------------------------------------------------
    I am now trying to get a margins output running:

    Code:
    margins n_comp#n_algo20
    or

    Code:
    margins, dydx(n_algo20) at(n_comp = (1(1)9))
    Most of this yields "not estimable" results. Can someone help out? I know that this is related to including fixed effects. However both n_algo and n_comp do vary within products to some extent as there is entry and exit. Is this related to the n_algo = 3 dummy in the main effect being ommitted?

    Code:
    . margins n_comp#n_algo20
    
    Predictive margins                              Number of obs     =  2,461,755
    Model VCE    : Robust
    
    Expression   : Linear prediction, predict()
    
    ---------------------------------------------------------------------------------
                    |            Delta-method
                    |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
    n_comp#n_algo20 |
               1 0  |          .  (not estimable)
               1 1  |          .  (not estimable)
               1 2  |          .  (not estimable)
               1 3  |          .  (not estimable)
               2 0  |          .  (not estimable)
               2 1  |          .  (not estimable)
               2 2  |          .  (not estimable)
               2 3  |          .  (not estimable)
               3 0  |          .  (not estimable)
               3 1  |          .  (not estimable)
               3 2  |          .  (not estimable)
               3 3  |          .  (not estimable)
               4 0  |   57.79425   .0338954  1705.08   0.000     57.72781    57.86068
               4 1  |          .  (not estimable)
               4 2  |          .  (not estimable)
               4 3  |          .  (not estimable)
               5 0  |    57.1761   .0393538  1452.87   0.000     57.09896    57.25323
               5 1  |          .  (not estimable)
               5 2  |          .  (not estimable)
               5 3  |          .  (not estimable)
               6 0  |          .  (not estimable)
               6 1  |          .  (not estimable)
               6 2  |          .  (not estimable)
               6 3  |          .  (not estimable)
               7 0  |   56.30857   .0287326  1959.74   0.000     56.25226    56.36489
               7 1  |          .  (not estimable)
               7 2  |          .  (not estimable)
               7 3  |          .  (not estimable)
               8 0  |          .  (not estimable)
               8 1  |   56.67136   .0742454   763.30   0.000     56.52584    56.81688
               8 2  |          .  (not estimable)
               8 3  |          .  (not estimable)
               9 0  |   56.56502   .0230195  2457.27   0.000      56.5199    56.61013
               9 1  |          .  (not estimable)
               9 2  |          .  (not estimable)
               9 3  |          .  (not estimable)
              10 0  |          .  (not estimable)
              10 1  |          .  (not estimable)
              10 2  |          .  (not estimable)
              10 3  |          .  (not estimable)
    ---------------------------------------------------------------------------------
    
    .
    Find some dataex input below. I am not sure how useful this is in reproducing the problem. I am using Stata 16 on Windows 10.

    Thank you all!

    marcello



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double bbox_price float bol_seller double rating float deliverytime byte n_comp int n_algo20 float bbox_prod_id
    12.5 1   .     1 4 0 179
    12.5 0 8.4     6 4 0 179
    12.5 0   9     6 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     6 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4     6 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     6 4 0 179
    12.5 0 8.4     6 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4     6 4 0 179
    12.5 0   9     6 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0   9     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4     5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9     5 4 0 179
    12.5 0   9   5.5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4   5.5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.4   5.5 4 0 179
    12.5 0   9   5.5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4   5.5 4 0 179
    12.5 0   9   5.5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0   9   5.5 4 0 179
    12.5 0 8.4   5.5 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0 8.4   5.5 4 0 179
    12.5 1   .     1 4 0 179
    12.5 0 8.9     1 4 0 179
    12.5 0   9   5.5 4 0 179
    12.5 0   9   5.5 3 0 179
    12.5 0 8.9     1 3 0 179
    12.5 1   .     1 3 0 179
    12.5 0   9   5.5 3 0 179
    12.5 0 8.9     1 3 0 179
    12.5 1   .     1 3 0 179
    12.5 0 8.9     1 3 0 179
    12.5 0   9   5.5 3 0 179
    12.5 1   .     1 3 0 179
    12.5 1   .     1 3 0 179
    12.5 0   9   5.5 3 0 179
    12.5 0 8.9     1 3 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .   7.5 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .   7.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .   7.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .   7.5 2 0 179
    12.5 1   .   7.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   . 136.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   . 136.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 1   . 136.5 2 0 179
    12.5 1   . 136.5 2 0 179
    12.5 0 8.9     1 2 0 179
    12.5 0   9     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 1   .     1 2 0 179
    12.5 0 8.9     1 2 0 179
    end
    Last edited by Marcel Wieting; 13 Sep 2020, 07:43.

  • #2
    Have you tried using the noestimcheck option?

    Code:
    margins n_comp#n_algo20, noestimcheck

    Comment


    • #3
      Hi Justin! Thanks for the swift reply.
      Running the above line does indeed yield values for all margins. However, it also yields values for combinations of n_algo#n_comp that should be empty (as there are no such observations, e.g. n_comp = 2 and n_algo = 3). How do I then interpret these values?


      Code:
       margins n_comp#n_algo20, noestimcheck
      
      Predictive margins                              Number of obs     =  2,461,755
      Model VCE    : Robust
      
      Expression   : Linear prediction, predict()
      
      
      ---------------------------------------------------------------------------------
                      |            Delta-method
                      |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
      ----------------+----------------------------------------------------------------
      n_comp#n_algo20 |
                 1 0  |   67.07535   .5350042   125.37   0.000     66.02677    68.12394
                 1 1  |   62.27336   .1589924   391.68   0.000     61.96174    62.58497
                 1 2  |   68.44333   .5372028   127.41   0.000     67.39043    69.49623
                 1 3  |   67.07535   .5350042   125.37   0.000     66.02677    68.12394
                 2 0  |   60.82286   .1092062   556.95   0.000     60.60882     61.0369
                 2 1  |   62.72851   .1773012   353.80   0.000     62.38101    63.07601
                 2 2  |   62.19084   .1244677   499.65   0.000     61.94688    62.43479
                 2 3  |   60.82286   .1092062   556.95   0.000     60.60882     61.0369
                 3 0  |   60.04122   .0498349  1204.80   0.000     59.94354    60.13889
                 3 1  |   60.75691   .1147216   529.60   0.000     60.53206    60.98176
                 3 2  |   57.36873   .1083936   529.26   0.000     57.15629    57.58118
                 3 3  |   60.04122   .0498349  1204.80   0.000     59.94354    60.13889
                 4 0  |    57.5212    .033744  1704.63   0.000     57.45507    57.58734
                 4 1  |   59.05206   .0636416   927.88   0.000     58.92732    59.17679
                 4 2  |   61.31951   .1026045   597.63   0.000     61.11841    61.52061
                 4 3  |    57.5212    .033744  1704.63   0.000     57.45507    57.58734
                 5 0  |   57.08161   .0392308  1455.02   0.000     57.00472     57.1585
                 5 1  |   60.18682   .0615324   978.13   0.000     60.06622    60.30743
                 5 2  |   60.40343   .0781993   772.43   0.000     60.25017     60.5567
                 5 3  |   57.08161   .0392308  1455.02   0.000     57.00472     57.1585
                 6 0  |   56.67805   .0363761  1558.11   0.000     56.60675    56.74934
                 6 1  |   57.52064   .0525143  1095.33   0.000     57.41772    57.62357
                 6 2  |   58.90077   .0597216   986.26   0.000     58.78372    59.01782
                 6 3  |   56.67805   .0363761  1558.11   0.000     56.60675    56.74934
                 7 0  |   56.52811   .0286585  1972.47   0.000     56.47194    56.58428
                 7 1  |   57.68535   .0582707   989.95   0.000     57.57114    57.79956
                 7 2  |   57.65587   .0570285  1011.00   0.000     57.54409    57.76764
                 7 3  |   56.52811   .0286585  1972.47   0.000     56.47194    56.58428
                 8 0  |   56.88125   .0220861  2575.43   0.000     56.83796    56.92454
                 8 1  |   57.08364   .0743112   768.17   0.000     56.93799    57.22929
                 8 2  |   58.95367   .0760832   774.86   0.000     58.80455    59.10279
                 8 3  |   56.88125   .0220861  2575.43   0.000     56.83796    56.92454
                 9 0  |   56.92815   .0229557  2479.91   0.000     56.88316    56.97314
                 9 1  |   56.90308   .0785738   724.20   0.000     56.74908    57.05708
                 9 2  |   57.91896   .0647439   894.59   0.000     57.79206    58.04585
                 9 3  |   59.62333   .0597516   997.85   0.000     59.50622    59.74044
                10 0  |   56.45332    .020505  2753.14   0.000     56.41313    56.49351
                10 1  |   57.11191   .0776842   735.18   0.000     56.95965    57.26417
                10 2  |    57.8213   .0606441   953.45   0.000     57.70244    57.94016
                10 3  |   56.45332    .020505  2753.14   0.000     56.41313    56.49351
      ---------------------------------------------------------------------------------

      Or taking it one step back: does margins yield "not estimable" as soon as there are some empty combinations in the interactions? For instance I tried:
      Code:
      margins n_comp#n_algo20 if n_algo <= n_comp
      to exclude all categories that are empty (there can't be more algorithmic sellers than sellers in total per product at any time).

      But my if-statement at the end is ignored and "not estimable" is returned only.
      Last edited by Marcel Wieting; 13 Sep 2020, 10:02.

      Comment


      • #4
        So to add to the above, as I think it might not be clear enough: I do have empty categories by construction in the interactions as n_algo is a subset of n_comp where it holds that n_algo <= n_comp always. Any categories where the previous condition does not hold is empty. Does that matter for the calculation of margins?

        Comment


        • #5
          Let me offer a slightly different perspective. What I would normally do is estimate the margins for one of the two main variables at values of the other interacting variable.

          Comment


          • #6
            Hi Phil,
            in Stata terms that would be
            Code:
             margins dydx(n_comp), at(n_algo20 = 0(1)3))
            However that is not changing the situation and margins are still "not estimable".

            Comment


            • #7
              The predictive margins are, in fact, mathematically not estimable following a fixed-effects regression. That's because fixed-effects regression estimates within-panel effects, and the predictive margins would be between-panel effects. However, the marginal effects are estimable, although Stata does not seem to recognize that. If you add the -noestimcheck- option to the command shown in #6, you will get correct results.

              Do not, however, in other work, indiscriminately use -noestimcheck- whenever Stata says things are not estimable. Stata is usually right when it says that. Use -noestimcheck- only in circumstances, like this one (marginal effects after fixed-effects regression), where the parameters in question really can be estimated. Otherwise, you will get meaningless answers.

              Comment


              • #8
                Dear Clyde, thank you for your reply. This is very helpful.
                Marcel

                Comment

                Working...
                X