Announcement

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

  • #31
    Akhzan:
    1) you -xtset- your panel dataset with -panelvar- and -timevar- to tell Stata that you're dealing with a panel dataset.
    2) you add -i.year- inn the right-hand side of your regression equation to test the contribution of time to variation in the dependent variable, when adjusted for the remaining predictors. The -fvvarlist- notation also informs Stata that -i.time- is a categorical variable;
    3) if you use -xtregar- you can add -i.time- only in the right-hand side of your regression equation.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #32
      Thank you very much Carlo, really appreciate that.
      It helps me a lot

      Best Regards,
      Akhzan

      Comment


      • #33
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float year str40(iso3_o iso3_d) double(tradeflow_imf_o tradeflow_imf_d) int dis_depth byte(MAS ADJ rta contig comlang_off comcol heg_o heg_d) float(pop_o pop_d gdp_o) double gdp_d
        1995 "ARE" "ARG"        0                  18 0 0 0 0 0 0 0 0 0  2346.305 34833.168  65743668      312569200.64
        1995 "ARE" "ATG"        0                   0 0 0 0 0 0 0 1 0 0  2346.305    68.349  65743668        494185.184
        1995 "ARE" "BHR"     88.9                 111 0 0 0 1 0 1 1 0 0  2346.305    563.73  65743668       5849467.904
        1995 "ARE" "BRA"    27.77  107.00000000000003 0 0 0 0 0 0 0 0 0  2346.305 161890.83  65743668     768951320.576
        1995 "ARE" "BRB"        0                   0 0 0 0 0 0 0 1 0 0  2346.305   263.165  65743668       2261969.664
        1995 "ARE" "BRN"     6.91                7600 0 0 0 0 0 0 1 0 0  2346.305   295.003  65743668       4734020.096
        1995 "ARE" "BWA"        0                   0 0 0 0 0 0 0 1 0 0  2346.305  1583.453  65743668       4730599.936
        1995 "ARE" "CHL"      .18   44.99999999999999 0 0 0 0 0 0 0 0 0  2346.305 14440.103  65743668      71349198.848
        1995 "ARE" "CHN"   108.87  1645.9999999999993 0 0 0 0 0 0 0 0 0  2346.305   1204855  65743668     728007573.504
        1995 "ARE" "COL"      .83     909.31201171875 0 0 0 0 0 0 0 0 0  2346.305 36573.895  65743668      92507275.264
        1995 "ARE" "CRI"      .01   .9999999999999996 0 0 0 0 0 0 0 0 0  2346.305  3478.197  65743668      11722356.736
        1995 "ARE" "CUB"        0                   0 0 0 0 0 0 0 0 0 0  2346.305 10932.013  65743668      30428639.232
        1995 "ARE" "DMA"      .01   8.208000183105469 0 0 0 0 0 0 1 0 0  2346.305    71.367  65743668         224037.04
        1995 "ARE" "DOM"        0                   0 0 0 0 0 0 0 0 0 0  2346.305  7977.966  65743668      16358496.256
        1995 "ARE" "ECU"        0                   4 0 0 0 0 0 0 0 0 0  2346.305   11315.8  65743668      24432379.904
        1995 "ARE" "GAB"        0                   0 0 0 0 0 0 0 0 0 0  2346.305  1080.477  65743668 4958845906.347692
        1995 "ARE" "GRD"        0 .024000000208616257 0 0 0 0 0 0 1 0 0  2346.305   100.253  65743668        276296.288
        1995 "ARE" "GUY"        0                   0 0 0 0 0 0 0 1 0 0  2346.305   728.136  65743668        621626.816
        1995 "ARE" "HKG"   368.07  197.99999999999991 0 0 0 0 0 0 1 0 0  2346.305    6156.1  65743668     144652910.592
        1995 "ARE" "KAZ"     4.73   .9999999999999996 0 0 0 0 0 0 0 0 0  2346.305 15815.626  65743668      20374306.816
        1995 "ARE" "KNA"        0                   0 0 0 0 0 0 0 1 0 0  2346.305    42.888  65743668        230740.736
        1995 "ARE" "KWT"   156.06                  55 0 0 0 1 0 1 1 0 0  2346.305  1586.123  65743668      27191687.168
        1995 "ARE" "LCA"        0   .5460000038146973 0 0 0 0 0 0 1 0 0  2346.305    147.04  65743668        560811.072
        1995 "ARE" "MAC"       .1  110.18599700927734 0 0 0 0 0 0 0 0 0  2346.305   398.459  65743668       6560672.256
        1995 "ARE" "MDV"    18.01     19810.365234375 0 0 0 0 0 0 1 0 0  2346.305   244.965  65743668         398988.96
        1995 "ARE" "MEX"        0                  25 0 0 0 0 0 0 0 0 0  2346.305  95392.65  65743668     343792779.264
        1995 "ARE" "MUS"        0                   0 0 0 0 0 0 0 1 0 0  2346.305  1122.457  65743668       4040342.016
        1995 "ARE" "MYS"    32.51                 373 0 0 0 0 0 0 1 0 0  2346.305 20725.373  65743668       88832450.56
        1995 "ARE" "OMN"    920.3   .9999999999999996 0 0 0 1 1 1 0 0 0  2346.305    2154.6  65743668      13802600.448
        1995 "ARE" "PAN"        0                   0 0 0 0 0 0 0 0 0 0  2346.305  2757.004  65743668       7906100.224
        1995 "ARE" "PER"      .77   .9999999999999996 0 0 0 0 0 0 0 0 0  2346.305  23939.26  65743668       52047687.68
        1995 "ARE" "QAT"   121.55                 151 0 0 0 1 1 1 1 0 0  2346.305   501.154  65743668       8137911.808
        1995 "ARE" "SAU"   331.51   750.9999999999995 0 0 0 1 1 1 0 0 0  2346.305 18567.344  65743668     142457683.968
        1995 "ARE" "SGP"  1305.08                 211 0 0 0 0 0 0 1 0 0  2346.305    3524.5  65743668        87891558.4
        1995 "ARE" "SUR"        0                   0 0 0 0 0 0 0 0 0 0  2346.305   435.776  65743668         693970.56
        1995 "ARE" "SYC"     1.22    1343.97998046875 0 0 0 0 0 0 1 0 0  2346.305    75.304  65743668        508213.504
        1995 "ARE" "THA"   616.78   441.0000000000002 0 0 0 0 0 0 0 0 0  2346.305  58983.95  65743668     168018558.976
        1995 "ARE" "TTO"      .02   22.19300079345703 0 0 0 0 0 0 1 0 0  2346.305  1255.001  65743668       5329213.952
        1995 "ARE" "TUR"    38.17  199.00000000000006 0 0 0 0 0 0 0 0 0  2346.305  58522.32  65743668     169485942.784
        1995 "ARE" "URY"        0  3.0000000000000013 0 0 0 0 0 0 0 0 0  2346.305  3224.383  65743668      19297662.976
        1995 "ARE" "VCT"        0                   0 0 0 0 0 0 0 1 0 0  2346.305   108.122  65743668        266481.472
        1995 "ARG" "ARE"        0               18000 0 0 0 0 0 0 0 0 0 34833.168  2346.305 312569216        65743667.2
        1995 "ARG" "ATG"        0                   0 0 0 0 0 0 0 0 0 0 34833.168    68.349 312569216        494185.184
        1995 "ARG" "BHR"        0   456.5190124511719 0 0 0 0 0 0 0 0 0 34833.168    563.73 312569216       5849467.904
        1995 "ARG" "BRA" 5343.885             6127277 0 0 0 1 1 0 0 0 0 34833.168 161890.83 312569216     768951320.576
        1995 "ARG" "BRB"        0  1009.9669799804688 0 0 0 0 0 0 0 0 0 34833.168   263.165 312569216       2261969.664
        1995 "ARG" "BRN"        0                   0 0 0 0 0 0 0 0 0 0 34833.168   295.003 312569216       4734020.096
        1995 "ARG" "BWA"        0                   0 0 0 0 0 0 0 0 0 0 34833.168  1583.453 312569216       4730599.936
        1995 "ARG" "CHL"  1403.18             1384500 0 0 0 1 1 1 0 0 0 34833.168 14440.103 312569216      71349198.848
        1995 "ARG" "CHN"  284.013              370397 0 0 0 0 0 0 0 0 0 34833.168   1204855 312569216     728007573.504
        1995 "ARG" "COL"  231.575        147518.34375 0 0 0 1 0 1 0 0 0 34833.168 36573.895 312569216      92507275.264
        1995 "ARG" "CRI"        0       27102.0234375 0 0 0 0 0 1 0 0 0 34833.168  3478.197 312569216      11722356.736
        1995 "ARG" "CUB"   65.084       71592.3984375 0 0 0 1 0 1 0 0 0 34833.168 10932.013 312569216      30428639.232
        1995 "ARG" "DMA"        0  15.187000274658203 0 0 0 0 0 0 0 0 0 34833.168    71.367 312569216         224037.04
        1995 "ARG" "DOM"        0                   0 0 0 0 0 0 1 0 0 0 34833.168  7977.966 312569216      16358496.256
        1995 "ARG" "ECU"    83562         75695.90625 0 0 0 1 0 1 0 0 0 34833.168   11315.8 312569216      24432379.904
        1995 "ARG" "GAB"        0                   0 0 0 0 0 0 0 0 0 0 34833.168  1080.477 312569216 4958845906.347692
        1995 "ARG" "GRD"        0  204.83900451660156 0 0 0 0 0 0 0 0 0 34833.168   100.253 312569216        276296.288
        1995 "ARG" "GUY"        0                   0 0 0 0 1 0 0 0 0 0 34833.168   728.136 312569216        621626.816
        1995 "ARG" "HKG"  277.752          295746.375 0 0 0 0 0 0 0 0 0 34833.168    6156.1 312569216     144652910.592
        1995 "ARG" "KAZ"     .112                .048 0 0 0 0 0 0 0 0 0 34833.168 15815.626 312569216      20374306.816
        1995 "ARG" "KNA"        0                   0 0 0 0 0 0 0 0 0 0 34833.168    42.888 312569216        230740.736
        1995 "ARG" "KWT"   16.425    15251.1103515625 0 0 0 0 0 0 0 0 0 34833.168  1586.123 312569216      27191687.168
        1995 "ARG" "LCA"        0  397.72601318359375 0 0 0 0 0 0 0 0 0 34833.168    147.04 312569216        560811.072
        1995 "ARG" "MAC"        0   243.6060028076172 0 0 0 0 0 0 0 0 0 34833.168   398.459 312569216       6560672.256
        1995 "ARG" "MDV"        0   31.83300018310547 0 0 0 0 0 0 0 0 0 34833.168   244.965 312569216         398988.96
        1995 "ARG" "MEX"  277.963            209775.5 0 0 0 1 0 1 0 0 0 34833.168  95392.65 312569216     343792779.264
        1995 "ARG" "MUS"        0         16449.71875 0 0 0 0 0 0 0 0 0 34833.168  1122.457 312569216       4040342.016
        1995 "ARG" "MYS"   257.57       257245.734375 0 0 0 1 0 0 0 0 0 34833.168 20725.373 312569216       88832450.56
        1995 "ARG" "OMN"        0     17255.419921875 0 0 0 0 0 0 0 0 0 34833.168    2154.6 312569216      13802600.448
        1995 "ARG" "PAN"        0    12198.1650390625 0 0 0 0 0 1 0 0 0 34833.168  2757.004 312569216       7906100.224
        1995 "ARG" "PER"  310.248            346681.5 0 0 0 1 0 1 0 0 0 34833.168  23939.26 312569216       52047687.68
        1995 "ARG" "QAT"        0   2197.802001953125 0 0 0 0 0 0 0 0 0 34833.168   501.154 312569216       8137911.808
        1995 "ARG" "SAU"   24.498       43243.5234375 0 0 0 0 0 0 0 0 0 34833.168 18567.344 312569216     142457683.968
        1995 "ARG" "SGP"  136.388       86742.0390625 0 0 0 1 0 0 0 0 0 34833.168    3524.5 312569216        87891558.4
        1995 "ARG" "SUR"        0   109.8010025024414 0 0 0 0 0 0 0 0 0 34833.168   435.776 312569216         693970.56
        1995 "ARG" "SYC"        0                   0 0 0 0 0 0 0 0 0 0 34833.168    75.304 312569216        508213.504
        1995 "ARG" "THA"        0       172556.203125 0 0 0 1 0 0 0 0 0 34833.168  58983.95 312569216     168018558.976
        1995 "ARG" "TTO"        0    3287.77197265625 0 0 0 1 0 0 0 0 0 34833.168  1255.001 312569216       5329213.952
        1995 "ARG" "TUR"  153.942       208616.984375 0 0 0 0 0 0 0 0 0 34833.168  58522.32 312569216     169485942.784
        1995 "ARG" "URY"  602.821         608636.0625 0 0 0 1 1 1 0 0 0 34833.168  3224.383 312569216      19297662.976
        1995 "ARG" "VCT"        0   243.1020050048828 0 0 0 0 0 0 0 0 0 34833.168   108.122 312569216        266481.472
        1995 "ATG" "ARE"        0                   0 0 0 0 0 0 0 1 0 0    68.349  2346.305  494185.2        65743667.2
        1995 "ATG" "ARG"        0                   0 0 0 0 0 0 0 0 0 0    68.349 34833.168  494185.2      312569200.64
        1995 "ATG" "BHR"        0                   0 0 0 0 0 0 0 1 0 0    68.349    563.73  494185.2       5849467.904
        1995 "ATG" "BRA"        0                   0 0 0 0 0 0 0 0 0 0    68.349 161890.83  494185.2     768951320.576
        1995 "ATG" "BRB"        0                   0 0 0 0 1 0 1 1 0 0    68.349   263.165  494185.2       2261969.664
        1995 "ATG" "BRN"        0                   0 0 0 0 0 0 0 1 0 0    68.349   295.003  494185.2       4734020.096
        1995 "ATG" "BWA"        0                   0 0 0 0 0 0 1 1 0 0    68.349  1583.453  494185.2       4730599.936
        1995 "ATG" "CHL"        0                   0 0 0 0 0 0 0 0 0 0    68.349 14440.103  494185.2      71349198.848
        1995 "ATG" "CHN"        0                   0 0 0 0 0 0 0 0 0 0    68.349   1204855  494185.2     728007573.504
        1995 "ATG" "COL"        0                   0 0 0 0 0 0 0 0 0 0    68.349 36573.895  494185.2      92507275.264
        1995 "ATG" "CRI"        0                   0 0 0 0 0 0 0 0 0 0    68.349  3478.197  494185.2      11722356.736
        1995 "ATG" "CUB"        0                   0 0 0 0 0 0 0 0 0 0    68.349 10932.013  494185.2      30428639.232
        1995 "ATG" "DMA"        0                   0 0 0 0 1 0 1 1 0 0    68.349    71.367  494185.2         224037.04
        1995 "ATG" "DOM"        0                   0 0 0 0 0 0 0 0 0 0    68.349  7977.966  494185.2      16358496.256
        1995 "ATG" "ECU"        0                   0 0 0 0 0 0 0 0 0 0    68.349   11315.8  494185.2      24432379.904
        1995 "ATG" "GAB"        0                   0 0 0 0 0 0 0 0 0 0    68.349  1080.477  494185.2 4958845906.347692
        1995 "ATG" "GRD"        0                   0 0 0 0 1 0 1 1 0 0    68.349   100.253  494185.2        276296.288
        1995 "ATG" "GUY"        0                   0 0 0 0 1 0 1 1 0 0    68.349   728.136  494185.2        621626.816
        end

        regression result
        Code:
        HDFE PPML regression                              No. of obs      =     48,072
        Absorbing 3 HDFE groups                           Residual df     =     44,068
        Statistics robust to heteroskedasticity           Wald chi2(4)    =      20.06
        Deviance             =  267696372.3               Prob > chi2     =     0.0005
        Log pseudolikelihood = -133967491.6               Pseudo R2       =     0.9961
        
        Number of clusters (imp#exp#year)=    48,072
                              (Std. Err. adjusted for 48,072 clusters in imp#exp#year)
        ------------------------------------------------------------------------------
                     |               Robust
        tradeflo~f_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
           dis_depth |
                  1  |   .0903637   .0420716     2.15   0.032      .007905    .1728224
                  2  |   .2382558   .1036588     2.30   0.022     .0350882    .4414234
                     |
                 rta |  -.1145223   .0414476    -2.76   0.006    -.1957581   -.0332864
              contig |          0  (omitted)
         comlang_off |          0  (omitted)
              comcol |          0  (omitted)
               heg_o |          0  (omitted)
               heg_d |          0  (omitted)
               pop_o |  -2.49e-10   1.24e-10    -2.01   0.045    -4.91e-10   -6.08e-12
               pop_d |          0  (omitted)
               gdp_o |          0  (omitted)
               gdp_d |          0  (omitted)
               _cons |   16.22802   .0200386   809.84   0.000     16.18874    16.26729
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
            imp#time |      1176           0        1176     |
            exp#time |      1175          28        1147     |
             imp#exp |      1719          42        1677    ?|
        -----------------------------------------------------+
        ? = number of redundant parameters may be higher
        although when I apply the same regression model to a different dataset with same dependent and independent variables, I don't get the above issue of omitting IVs.
        please help @clyde @carlo
        Last edited by Dr. Iqra Yaseen; 13 Jul 2023, 04:06.

        Comment


        • #34
          Your example data does not contain the variables imp, exp, and time that define the absorbed effects in your regression. But I'm going to guess that year is time, imp is iso3_d, and exp is iso3_o. If I have that right, all of the omitted variables are invariant within at least one of the absorbed effects--so their effects are not estimable in a fixed effects model.

          Comment


          • #35
            @Clyde, but when i apply the same regression model on another dataset with same variables, i get the requisite estimates.
            yes you are right about the imp, exp and time variables.

            Comment


            • #36
              I can only conclude that in the other data set, these variables do vary within all of the absorbed effects. That might mean that the data in that other data set are erroneous, since the names of some of those variables, ending in _o and _d, suggest that they are unchanging attributes of the exporter and importer, respectively.

              Comment


              • #37
                Clyde Schechter i guess there is some misconception. Variables ending in _o and _d are not any attributes of importer and exporter countries rather they are the iso3 codes of imp and exp countries. plus i forgot to mention the regression command which is like
                Code:
                ppmlhdfe tradeflowimf_d i.dis_depth rta contiguity comcol comlang heg_o heg_d pop_o pop_d gdp_o gdp_d, a(imp#time exp#time imp#exp) d cluster (imp#exp#year)
                Last edited by Dr. Iqra Yaseen; 13 Jul 2023, 11:38.

                Comment


                • #38
                  The omitted variables in 33 are contig, comlang_off, comcol, heg_o, heg_d, pop_o (not literally omitted but the coefficient is effectively 0, so for practical purposes, this, too, is omitted), pop_d, gdp_o, and gdp_d. I don't know what these variables represent in the real world, but the *_o and *_d ones, by virtue of their names, suggest that they represent fixed attributes of the exporter (iso3_o) and importer (iso3_d) countries respectively.

                  When I check this, in fact, heg_o, pop_o, and gdp_o are all constant within iso3_o, and heg_d, pop_d, and gdp_d are all constant within iso3_d within your example data, and, I assume, in your full data set. Since iso3_o and iso3_d are part of the interactions that are absorbed, these variables' effects cannot be estimated in a fixed effects model.

                  As for contig, comlang_off, and comcol, these are all constant within iso3_o#iso3_d in your example data, and, I assume, in your full data set. Since iso3_o#iso3_d is one of the absorbed effects, these variables' effects cannot be estimated in a fixed effects model.

                  As for why you were able to run this regression and get estimates of these variables in a different data set, the only conclusion I can draw is that in the other data set, these variables vary within iso3_o, iso3_d, and iso3_o#iso3_d in that other data set. Whether that is because that other data set is, perhaps, more refined, say, with year-specific estimates of these variables rather than time-invariant ones, or because despite these variables being supposed to be invariant within countries or country pairs, the other data set contains errors in the data on these variables, I cannot say.

                  Comment


                  • #39
                    Clyde Schechter so what do you suggest? should i change my research model?

                    Comment


                    • #40
                      Clyde Schechter so what do you suggest? should i change my research model (FE)?

                      Comment


                      • #41
                        It depends on youor research goals. Why are you including these variables anyway? Do you actually need to estimate their effects on the outcome in order to answer your research question? If so, then, yes, you need to use a different model. Consider using a random-effects Poisson model (-xtpoisson, re-). Or -xthybrid- with -family(poisson)- and -link(log)- specified. (Added: -xthybrid- is available from SSC.)

                        Or are they just there as "control variables?" In that case, you can keep your fixed-effects model and just ignore the omitted variables. The adjustment for their effects is automatically taken care of, as are any fixed attributes of the absorbed effect categories, even if there are no variables measuring them. That, in fact, is one of the strengths of the fixed-effects model: the automatic adjustment for time-invariant attributes.

                        Comment


                        • #42
                          yes you are right they are just the control variables....but if i simply ignore them then how could i justify this ignoring of control variables in my thesis. would it be wise to just write "control variables ignored on account of being omitted by FE model"? does it make any sense. please clarify Clyde Schechter also i can't use anything besides PPMLHDFE model for being one of the basic pillars of my research.

                          Comment


                          • #43
                            You say: "Variables contig, comlang_off, comcol, heg_o, heg_d, pop_o , pop_d, gdp_o, and gdp_d are time-invariant attributes of the import-export dyads or the importer and exporter countries As such, they are colinear with the absorbed fixed effects, and are therefore omitted from the regression. Their effects are automatically adjusted for by the absorbed fixed effects themselves."
                            Last edited by Clyde Schechter; 14 Jul 2023, 12:50.

                            Comment


                            • #44
                              thank you so much Clyde Schechter . much helpful.

                              Comment

                              Working...
                              X