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