Announcement

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

  • margins with interaction term

    Hello everyone,

    I am having troubles getting my margins with following commands (it just gives me "not estimable"):

    reg log_co2_capita c.log_gdp_capita##c.log_gdp_capita##i.dum1986 oil_country oil_gdp_capita log_num_years_demo i.country i.year, vce(robust)

    summarize log_gdp_capita if electoral_2==1
    global MyMin = r(min)
    global MyMax = r(max)
    global Grid = (15-$MyMin)/100

    margins, dydx(c.log_gdp_capita) at(c.log_gdp_capita=($MyMin($Grid)15) dum1986=(0))

    I want to get so I can plot two marginsplot, one where the margins are with dum1986 = 0 and a plot with dum1986 = 1.

    The code works just fine if I am not trying to split the margins upon the dum1986 but just running following: margins, dydx(c.log_gdp_capita) at(c.log_gdp_capita=($MyMin($Grid)15))

    How can I solve this?

    Best Rasmus

  • #2
    You are more likely to get a timely and helpful response if you provide more information. There is nothing obviously wrong with the code, and with "not estimable" problems, the trouble is almost always with the model or the data (or both). I suggest you post back showing, a) example data that includes all variable necessary to run the regression command, b) the complete output you get from the -regress- command (including all messages that appear before the regression table itself), and c) the output of the -margins- command, again including any messages there might be.

    So that the example data will be helpful for troubleshooting, you should use the -dataex- command to post it. Also, you should run the regression and margins commands on the example data to verify that it reproduces the problem you are having.

    If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      You are more likely to get a timely and helpful response if you provide more information. There is nothing obviously wrong with the code, and with "not estimable" problems, the trouble is almost always with the model or the data (or both). I suggest you post back showing, a) example data that includes all variable necessary to run the regression command, b) the complete output you get from the -regress- command (including all messages that appear before the regression table itself), and c) the output of the -margins- command, again including any messages there might be.

      So that the example data will be helpful for troubleshooting, you should use the -dataex- command to post it. Also, you should run the regression and margins commands on the example data to verify that it reproduces the problem you are having.

      If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.
      Thanks for reply.

      A)
      . dataex year log_co2_capita log_gdp_capita oil_gdp_capita oil_country log_num_years_demo dum1986 id, count(200)

      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int year float(log_co2_capita log_gdp_capita oil_gdp_capita oil_country log_num_years_demo dum1986 id)
      1950 -4.4860005  7.052721         0 0         0 0 1
      1951 -4.4147205  7.064759         0 0         0 0 1
      1952  -4.427319  7.080868         0 0         0 0 1
      1953 -4.2914724  7.122867         0 0         0 0 1
      1954  -4.304236  7.126891         0 0         0 0 1
      1955  -3.947457  7.127694         0 0         0 0 1
      1956  -3.787525  7.153052         0 0         0 0 1
      1957 -3.3325515  7.133296         0 0         0 0 1
      1958  -3.229713   7.16858         0 0         0 0 1
      1959  -3.091947   7.17549         0 0         0 0 1
      1960  -3.036539  7.189922         0 0         0 0 1
      1961  -2.885353  7.177019         0 0         0 0 1
      1962  -2.566884  7.171657         0 0         0 0 1
      1963  -2.561667   7.16858         0 0         0 0 1
      1964  -2.412045  7.163172         0 0         0 0 1
      1965 -2.2512336  7.162397         0 0         0 0 1
      1966 -2.1934214  7.148346         0 0         0 0 1
      1967 -2.0552723  7.152269         0 0         0 0 1
      1968 -2.1254349  7.162397         0 0         0 0 1
      1969  -2.411416  7.153052         0 0         0 0 1
      1970  -1.862121  7.148346         0 0         0 0 1
      1971   -1.76088  7.120444         0 0         0 0 1
      1972 -1.9981352  6.914731         0 0         0 0 1
      1973 -1.9569538  6.918695         0 0         0 0 1
      1974  -1.825252  6.946014         0 0         0 0 1
      1975  -1.745869  6.979145         0 0         0 0 1
      1976  -1.836202  7.007601         0 0         0 0 1
      1977  -1.671749  6.929517         0 0         0 0 1
      1978  -1.793234  6.975414         0 0         0 0 1
      1979  -1.760665  6.930495         0 0         0 0 1
      1980 -1.9614488  6.926577         0 0         0 0 1
      1981  -1.729585  7.042286         0 0         0 0 1
      1982  -1.572022  7.146772         0 0         0 0 1
      1983 -1.3734773  7.205635         0 0         0 0 1
      1984  -1.289379  7.198184         0 0         0 0 1
      1985 -1.0993692  7.173192         0 0         0 0 1
      1986 -1.2042565  7.203405         0 0         0 1 1
      1987 -1.1984997  7.099202         0 0         0 1 1
      1988 -1.2904783  7.003974         0 0         0 1 1
      1989  -1.350745  6.906755         0 0         0 1 1
      1990 -1.6645212  6.870053         0 0         0 1 1
      1991 -1.7251036  6.781251         0 0         0 1 1
      1992 -2.0962527  6.738005         0 0         0 1 1
      1993 -2.2426038  6.360271         0 0         0 1 1
      1994  -2.363768  6.060115         0 0         0 1 1
      1995  -2.449661  6.450376         0 0         0 1 1
      1996  -2.524578  6.397222         0 0         0 1 1
      1997  -2.613017  6.346685         0 0         0 1 1
      1998  -2.671709  6.300857         0 0         0 1 1
      1999 -2.8704975  6.251245         0 0         0 1 1
      2000 -2.9265654  6.219342         0 0         0 1 1
      2001  -2.913226  6.193756         0 0         0 1 1
      2002  -2.751123  6.680624         0 0         0 1 1
      2003 -2.6755145  6.736736         0 0         0 1 1
      2004  -2.946388  6.767388         0 0         0 1 1
      2005  -2.558726  6.871514         0 0         0 1 1
      2006  -2.466646  6.963281         0 0         0 1 1
      2007 -2.2247837  7.138865         0 0         0 1 1
      2008  -1.826422   7.18509         0 0         0 1 1
      2009  -1.454977  7.350722         0 0         0 1 1
      2010  -1.214923  7.394906         0 0         0 1 1
      2011  -.9045094  7.491087         0 0         0 1 1
      2012 -1.1105169  7.573017         0 0         0 1 1
      2013 -1.2266164  7.613325         0 0         0 1 1
      2014 -1.2718998  7.611843         0 0         0 1 1
      2015  -1.237611  7.564239         0 0         0 1 1
      2016 -1.3401924  7.564757         0 0         0 1 1
      2017 -1.2842704  7.608248         0 0         0 1 1
      2018  -1.221201  7.567633         0 0         0 1 1
      2019 -1.2262138  7.549066         0 0         0 1 1
      2020 -1.1873144  7.493927         0 0         0 1 1
      2021 -1.1831347  7.232991         0 0         0 1 1
      1950 -1.4401605  7.375256         0 0         0 0 2
      1951 -1.1628684  7.418181         0 0         0 0 2
      1952 -1.2672733  7.418781         0 0         0 0 2
      1953  -1.194388  7.459339         0 0         0 0 2
      1954 -1.0322244  7.487174         0 0         0 0 2
      1955  -.7851053   7.54009         0 0         0 0 2
      1956 -.58167773  7.550661         0 0         0 0 2
      1957 -.02878458  7.612337         0 0         0 0 2
      1958   -.287078  7.656337         0 0         0 0 2
      1959 -.13686895  7.696667         0 0         0 0 2
      1960  .16701297  7.746301         0 0         0 0 2
      1961   .2530744  7.754481         0 0         0 0 2
      1962   .2975151  7.786967         0 0         0 0 2
      1963   .0969865  7.820439         0 0         0 0 2
      1964 .033141118  7.853993         0 0         0 0 2
      1965  .07768985  7.889834         0 0         0 0 2
      1966  .20804445  7.926602         0 0         0 0 2
      1967  .22761075  7.964156         0 0         0 0 2
      1968  .33502355  7.999343         0 0         0 0 2
      1969   .3607004  8.032685         0 0         0 0 2
      1970    .475343  8.069029         0 0         0 0 2
      1971   .5985032  8.108322         0 0         0 0 2
      1972   .8313248   8.14642         0 0         0 0 2
      1973   .7407044  8.195058         0 0         0 0 2
      1974   .5183203  8.198915         0 0         0 0 2
      1975  .54952735 8.2022085         0 0         0 0 2
      1976   .6005585  8.206584         0 0         0 0 2
      1977   .7229262  8.210939         0 0         0 0 2
      1978   .8290063  8.215007         0 0         0 0 2
      1979   .9652082  8.220403         0 0         0 0 2
      1980   .5640639  8.227108         0 0         0 0 2
      1981   .8972146  8.232706         0 0         0 0 2
      1982   .8766676  8.238273         0 0         0 0 2
      1983   .9047014  8.244071         0 0         0 0 2
      1984   .9158533  8.249576         0 0         0 0 2
      1985   .9102471  8.254789         0 0         0 0 2
      1986   .9212987   8.26101         0 0         0 1 2
      1987    .832966  8.267192         0 0         0 1 2
      1988   .8092165  8.273847         0 0         0 1 2
      1989  1.0071766  8.280965         0 0         0 1 2
      1990  .51605856   8.28979         0 0         0 1 2
      1991   .2617847  7.986879         0 0         0 1 2
      1992 -.27194077  7.952181         0 0         0 1 2
      1993  -.3448437   8.05103         0 0  .6931472 1 2
      1994 -.53779745  8.131446         0 0 1.0986123 1 2
      1995  -.4524581  8.207034         0 0 1.3862944 1 2
      1996  -.4833354  8.285434         0 0         0 1 2
      1997  -.7460648  8.168199         0 0         0 1 2
      1998  -.6108554  8.261881         0 0  .6931472 1 2
      1999 -.07172997  8.396616         0 0 1.0986123 1 2
      2000 -.05063179  8.478136         0 0 1.3862944 1 2
      2001  .02103569  8.572781         0 0  1.609438 1 2
      2002  .18232347  8.632121         0 0 1.7917595 1 2
      2003  .33028916  8.700289         0 0   1.94591 1 2
      2004   .3102439  8.767153         0 0 2.0794415 1 2
      2005   .3401686   8.83324         0 0 2.1972246 1 2
      2006  .26397818  8.902092         0 0 2.3025851 1 2
      2007  .28284478  8.970325         0 0  2.397895 1 2
      2008   .3985544  9.050422         0 0  2.484907 1 2
      2009   .4079014  9.089242         0 0  2.564949 1 2
      2010   .4959273  9.129453         0 0 2.6390574 1 2
      2011   .6055338  9.157361         0 0   2.70805 1 2
      2012   .5169767  9.168685         0 0  2.772589 1 2
      2013   .6051145  9.175749         0 0  2.833213 1 2
      2014   .7324882  9.190953         0 0  2.890372 1 2
      2015   .4914913  9.213535         0 0  2.944439 1 2
      2016   .4748245  9.243969         0 0  2.995732 1 2
      2017   .6088259  9.278197         0 0 3.0445225 1 2
      2018     .53145  9.315076         0 0 3.0910425 1 2
      2019   .5185495  9.430714         0 0  3.135494 1 2
      2020  .56000113  9.402877         0 0  3.178054 1 2
      2021     .54101  9.497484         0 0  3.218876 1 2
      2022   .5557227  9.557064         0 0 3.2580965 1 2
      1950  -.8687522  7.685244  7.685244 1         0 0 3
      1951  -.8084084  7.671827  7.671827 1         0 0 3
      1952  -.8953685  7.693026  7.693026 1         0 0 3
      1953  -.8934432  7.687997  7.687997 1         0 0 3
      1954  -.8800764  7.736743  7.736743 1         0 0 3
      1955  -.7990406  7.741968  7.741968 1         0 0 3
      1956  -.7403684  7.813996  7.813996 1         0 0 3
      1957  -.6590798  7.900637  7.900637 1         0 0 3
      1958  -.7404877  7.915713  7.915713 1         0 0 3
      1959  -.6798379  8.064008  8.064008 1         0 0 3
      1960  -.6164603 8.1101265 8.1101265 1         0 0 3
      1961  -.6498494   7.96137   7.96137 1         0 0 3
      1962  -.7326536  7.733684  7.733684 1         0 0 3
      1963  -.7924178  7.943783  7.943783 1         0 0 3
      1964  -.7692975  7.965199  7.965199 1         0 0 3
      1965  -.6308535  8.000014  8.000014 1         0 0 3
      1966  -.4040474  7.919356  7.919356 1         0 0 3
      1967  -.4250191  7.974877  7.974877 1         0 0 3
      1968  -.3767424  8.055475  8.055475 1         0 0 3
      1969  -.1805043  8.118207  8.118207 1         0 0 3
      1970  .08760063  8.184514  8.184514 1         0 0 3
      1971  .27891812  8.067149  8.067149 1         0 0 3
      1972   .6736767  8.228444  8.228444 1         0 0 3
      1973    .951147  8.231376  8.231376 1         0 0 3
      1974   .7436359   8.26101   8.26101 1         0 0 3
      1975    .710541  8.299037  8.299037 1         0 0 3
      1976   .8635251  8.332549  8.332549 1         0 0 3
      1977    .892894  8.388906  8.388906 1         0 0 3
      1978  1.2646984 8.4788685 8.4788685 1         0 0 3
      1979   .9191071   8.53464   8.53464 1         0 0 3
      1980   1.265318  8.521981  8.521981 1         0 0 3
      1981   .8732858  8.515391  8.515391 1         0 0 3
      1982   .6722514   8.54578   8.54578 1         0 0 3
      1983   .9316186   8.56465   8.56465 1         0 0 3
      1984   1.198838 8.5869055 8.5869055 1         0 0 3
      1985  1.1880243  8.606851  8.606851 1         0 0 3
      1986  1.2014155  8.568267  8.568267 1         0 1 3
      1987  1.2687714   8.53464   8.53464 1         0 1 3
      1988  1.2392062  8.486734  8.486734 1         0 1 3
      1989  1.1651803  8.494743  8.494743 1         0 1 3
      1990  1.1010051 8.4546795 8.4546795 1         0 1 3
      1991  1.1037662 8.4570675 8.4570675 1         0 1 3
      1992  1.0940961   8.48678   8.48678 1         0 1 3
      1993   1.097161  8.479891  8.479891 1         0 1 3
      1994  1.1542745 8.4881735 8.4881735 1         0 1 3
      1995  1.2232758  8.545272  8.545272 1         0 1 3
      1996  1.2387984  8.603671  8.603671 1         0 1 3
      1997  1.0979486   8.63737   8.63737 1         0 1 3
      1998  1.2698052  8.711077  8.711077 1         0 1 3
      1999   1.103115  8.767408  8.767408 1         0 1 3
      2000  1.0206393  8.829746  8.829746 1         0 1 3
      2001   1.023609  8.884367  8.884367 1         0 1 3
      2002   1.053535  8.963779  8.963779 1         0 1 3
      2003  1.0819719  9.058374  9.058374 1         0 1 3
      2004   1.037124  9.125032  9.125032 1         0 1 3
      end
      ------------------ copy up to and including the previous line ------------------

      Listed 200 out of 10470 observations


      B)
      . reg log_co2_capita c.log_gdp_capita##c.log_gdp_capita##i.dum1986 oil_country oil_gdp_capita log_num_years_demo i.id i.year if electoral_2 == 1, vce(robust)
      note: log_num_years_demo omitted because of collinearity.
      note: 150.id omitted because of collinearity.
      note: 2022.year omitted because of collinearity.

      Linear regression Number of obs = 3,088
      F(189, 2896) = .
      Prob > F = .
      R-squared = 0.9453
      Root MSE = .49498

      -----------------------------------------------------------------------------------------------------------
      | Robust
      log_co2_capita | Coefficient std. err. t P>|t| [95% conf. interval]
      ------------------------------------------+----------------------------------------------------------------
      log_gdp_capita | 2.447508 .3860021 6.34 0.000 1.690642 3.204375
      |
      c.log_gdp_capita#c.log_gdp_capita | -.1051254 .0231573 -4.54 0.000 -.1505317 -.059719
      |
      1.dum1986 | 2.417892 1.49325 1.62 0.106 -.5100487 5.345832
      |
      dum1986#c.log_gdp_capita |
      1 | -.3123923 .3750778 -0.83 0.405 -1.047839 .423054
      |
      dum1986#c.log_gdp_capita#c.log_gdp_capita |
      1 | .0240187 .0233163 1.03 0.303 -.0216995 .0697368
      |
      oil_country | 1.725817 .7411381 2.33 0.020 .2726058 3.179028
      oil_gdp_capita | .1332774 .0780715 1.71 0.088 -.0198039 .2863588
      log_num_years_demo | 0 (omitted)
      |
      id |
      2 | 1.648538 .1215444 13.56 0.000 1.410216 1.886861
      3 | -1.351147 .2437722 -5.54 0.000 -1.829132 -.8731627
      4 | -1.9077 .3141311 -6.07 0.000 -2.523643 -1.291757
      5 | 1.596562 .1711483 9.33 0.000 1.260977 1.932147
      6 | 1.067704 .1470488 7.26 0.000 .7793737 1.356035
      9 | 2.223471 .1413519 15.73 0.000 1.946311 2.500632
      10 | 3.367411 .1560406 21.58 0.000 3.06145 3.673373
      11 | -.4235637 .0930608 -4.55 0.000 -.6060358 -.2410915
      12 | 2.437219 .1492637 16.33 0.000 2.144545 2.729892
      14 | -.7732361 .0932373 -8.29 0.000 -.9560543 -.590418
      15 | .513396 .131199 3.91 0.000 .2561432 .7706487
      16 | 1.93069 .1422626 13.57 0.000 1.651743 2.209636
      18 | -1.765334 .2719834 -6.49 0.000 -2.298635 -1.232034
      19 | 2.457432 .1502158 16.36 0.000 2.162891 2.751972
      20 | -1.39391 .1027819 -13.56 0.000 -1.595444 -1.192377
      21 | -1.503362 .1000558 -15.03 0.000 -1.69955 -1.307174
      22 | -1.110661 .1756536 -6.32 0.000 -1.45508 -.7662425
      23 | -.0573685 .1406798 -0.41 0.683 -.3332112 .2184742
      25 | .4353536 .1703661 2.56 0.011 .1013026 .7694047
      26 | -.8899644 .0950735 -9.36 0.000 -1.076383 -.703546
      27 | -.8229522 .0967376 -8.51 0.000 -1.012634 -.6332706
      28 | 1.028322 .1492506 6.89 0.000 .7356734 1.32097
      29 | -.9523986 .2610571 -3.65 0.000 -1.464275 -.440522
      31 | -.0973981 .1113515 -0.87 0.382 -.3157343 .120938
      32 | .4236528 .1285993 3.29 0.001 .1714975 .6758081
      34 | .3041823 .1116403 2.72 0.006 .0852799 .5230847
      35 | 1.491855 .1560842 9.56 0.000 1.185808 1.797903
      36 | 1.716017 .1233059 13.92 0.000 1.47424 1.957793
      37 | 1.736282 .1602546 10.83 0.000 1.422057 2.050506
      38 | 3.01656 .1583897 19.05 0.000 2.705992 3.327128
      39 | -.0288111 .0818987 -0.35 0.725 -.1893967 .1317745
      41 | .6744261 .1018897 6.62 0.000 .4746425 .8742097
      42 | .9241054 .1234376 7.49 0.000 .6820709 1.16614
      43 | .5285162 .1362006 3.88 0.000 .2614564 .7955761
      44 | 1.314244 .1253197 10.49 0.000 1.068519 1.559969
      45 | .1864795 .1215504 1.53 0.125 -.0518546 .4248136
      46 | .2379298 .178308 1.33 0.182 -.1116936 .5875531
      47 | 3.066098 .1664605 18.42 0.000 2.739705 3.392491
      48 | -1.092014 .1001097 -10.91 0.000 -1.288308 -.8957208
      51 | 2.210651 .1525905 14.49 0.000 1.911454 2.509848
      53 | 1.06066 .1556781 6.81 0.000 .7554089 1.365911
      55 | .0441718 .0975721 0.45 0.651 -.1471459 .2354895
      56 | 1.593117 .1631522 9.76 0.000 1.273211 1.913023
      57 | -.2854558 .1308733 -2.18 0.029 -.54207 -.0288416
      58 | .5744065 .0905277 6.35 0.000 .3969013 .7519116
      59 | -.2459374 .102417 -2.40 0.016 -.446755 -.0451197
      60 | -.6811488 .1054293 -6.46 0.000 -.8878728 -.4744248
      61 | .4430737 .1124022 3.94 0.000 .2226774 .66347
      62 | 1.276167 .1625687 7.85 0.000 .9574049 1.594929
      63 | 2.498227 .1597755 15.64 0.000 2.184942 2.811513
      66 | .7180703 .1129269 6.36 0.000 .496645 .9394956
      67 | -1.140505 .2379792 -4.79 0.000 -1.607131 -.6738794
      68 | -1.195267 .2323351 -5.14 0.000 -1.650826 -.7397079
      74 | 1.226601 .1344595 9.12 0.000 .9629548 1.490247
      75 | 2.733816 .1529407 17.87 0.000 2.433932 3.033699
      76 | .3008729 .1045182 2.88 0.004 .0959352 .5058106
      77 | -.4135611 .2914684 -1.42 0.156 -.9850675 .1579454
      78 | 2.087349 .1696158 12.31 0.000 1.754769 2.419929
      79 | 1.47854 .1278396 11.57 0.000 1.227874 1.729206
      80 | 1.316887 .1762688 7.47 0.000 .9712617 1.662512
      81 | .1831241 .1558692 1.17 0.240 -.1225016 .4887498
      82 | -.5198649 .2395862 -2.17 0.030 -.9896416 -.0500882
      83 | 2.29192 .161474 14.19 0.000 1.975305 2.608536
      85 | -.5716093 .0959483 -5.96 0.000 -.7597432 -.3834755
      86 | -.1994278 .0994415 -2.01 0.045 -.3944111 -.0044444
      87 | 1.84681 .2065761 8.94 0.000 1.441759 2.251861
      88 | -1.007024 .0893089 -11.28 0.000 -1.182139 -.8319086
      90 | .6890059 .1245368 5.53 0.000 .4448162 .9331956
      93 | 2.320207 .1472744 15.75 0.000 2.031434 2.60898
      94 | 2.804123 .0898839 31.20 0.000 2.62788 2.980366
      95 | 1.637082 .1356367 12.07 0.000 1.371128 1.903037
      96 | .8036897 .1300296 6.18 0.000 .5487297 1.05865
      97 | -.4748767 .1690771 -2.81 0.005 -.8064004 -.143353
      98 | -.1178081 .0940065 -1.25 0.210 -.3021345 .0665182
      100 | -1.76455 .2074507 -8.51 0.000 -2.171316 -1.357784
      103 | .3077333 .1149496 2.68 0.007 .082342 .5331246
      104 | -.8181719 .1239758 -6.60 0.000 -1.061262 -.5750823
      105 | -1.782568 .2808912 -6.35 0.000 -2.333335 -1.231801
      106 | 2.367688 .113126 20.93 0.000 2.145873 2.589504
      107 | 1.992505 .146559 13.60 0.000 1.705135 2.279876
      109 | -1.448679 .2940058 -4.93 0.000 -2.02516 -.8721969
      110 | .8071738 .1167611 6.91 0.000 .5782305 1.036117
      111 | 1.199527 .1413214 8.49 0.000 .9224258 1.476627
      113 | .8802413 .1398337 6.29 0.000 .6060577 1.154425
      115 | 2.947206 .1554217 18.96 0.000 2.642458 3.251954
      117 | .1878428 .2470651 0.76 0.447 -.2965983 .6722839
      118 | 3.003141 .1251068 24.00 0.000 2.757834 3.248448
      119 | -.0273842 .223397 -0.12 0.902 -.4654175 .410649
      120 | -1.225804 .1235428 -9.92 0.000 -1.468045 -.9835634
      121 | -.970289 .2420793 -4.01 0.000 -1.444954 -.495624
      122 | .1410983 .2042969 0.69 0.490 -.2594837 .5416804
      123 | 2.171202 .1468796 14.78 0.000 1.883202 2.459201
      124 | -.2995944 .1308289 -2.29 0.022 -.5561215 -.0430672
      126 | 2.415 .155141 15.57 0.000 2.110802 2.719197
      127 | 1.962413 .1712615 11.46 0.000 1.626606 2.298219
      130 | 1.843307 .1627086 11.33 0.000 1.52427 2.162343
      131 | -.6309087 .1167208 -5.41 0.000 -.859773 -.4020444
      134 | .8623093 .1499973 5.75 0.000 .568197 1.156422
      135 | 1.356536 .1422084 9.54 0.000 1.077696 1.635376
      136 | .106755 .097871 1.09 0.275 -.0851488 .2986587
      137 | .7934478 .1503094 5.28 0.000 .4987236 1.088172
      138 | -.0234167 .1090755 -0.21 0.830 -.2372901 .1904567
      140 | 1.034039 .1227703 8.42 0.000 .7933127 1.274765
      141 | 1.109223 .1503654 7.38 0.000 .8143888 1.404057
      142 | 2.620819 .1310139 20.00 0.000 2.363929 2.877709
      143 | -.8115912 .0956225 -8.49 0.000 -.9990862 -.6240963
      144 | 2.808496 .1449996 19.37 0.000 2.524183 3.092809
      145 | -.887888 .3199692 -2.77 0.006 -1.515278 -.2604976
      148 | .8738072 .1629157 5.36 0.000 .5543648 1.193249
      149 | 2.012543 .1370214 14.69 0.000 1.743873 2.281212
      150 | 0 (omitted)
      151 | .739769 .1088493 6.80 0.000 .5263391 .9531989
      152 | .558662 .1716756 3.25 0.001 .2220433 .8952807
      153 | 1.02018 .1012807 10.07 0.000 .8215906 1.21877
      |
      year |
      1951 | -.104174 .2177826 -0.48 0.632 -.5311984 .3228505
      1952 | .1609452 .1829899 0.88 0.379 -.1978585 .5197488
      1953 | .1181091 .1790174 0.66 0.509 -.2329052 .4691235
      1954 | .3282822 .1675145 1.96 0.050 -.0001774 .6567419
      1955 | .3542887 .1619655 2.19 0.029 .0367095 .6718679
      1956 | .394283 .1674571 2.35 0.019 .0659359 .7226301
      1957 | .4288074 .1633845 2.62 0.009 .1084456 .7491691
      1958 | .4339267 .1670798 2.60 0.009 .1063193 .7615341
      1959 | .4016474 .1961776 2.05 0.041 .0169855 .7863093
      1960 | .4473872 .1955958 2.29 0.022 .0638661 .8309083
      1961 | .4838388 .1908222 2.54 0.011 .1096778 .8579998
      1962 | .5302446 .1834892 2.89 0.004 .170462 .8900272
      1963 | .6117313 .1842562 3.32 0.001 .2504447 .9730179
      1964 | .6047214 .1946389 3.11 0.002 .2230767 .9863661
      1965 | .6476553 .186653 3.47 0.001 .2816692 1.013641
      1966 | .6514841 .1805471 3.61 0.000 .2974703 1.005498
      1967 | .7282828 .1568411 4.64 0.000 .4207514 1.035814
      1968 | .7844765 .1657474 4.73 0.000 .4594818 1.109471
      1969 | .9080472 .1650974 5.50 0.000 .5843268 1.231768
      1970 | 1.015652 .1618504 6.28 0.000 .698298 1.333005
      1971 | 1.055495 .1571011 6.72 0.000 .7474538 1.363536
      1972 | 1.04451 .1574125 6.64 0.000 .7358585 1.353162
      1973 | 1.126949 .1579138 7.14 0.000 .8173138 1.436583
      1974 | 1.095542 .1592347 6.88 0.000 .7833171 1.407767
      1975 | 1.128957 .1585563 7.12 0.000 .8180624 1.439852
      1976 | 1.126139 .1582136 7.12 0.000 .8159166 1.436362
      1977 | 1.116516 .1585513 7.04 0.000 .8056307 1.4274
      1978 | 1.145718 .1612799 7.10 0.000 .829483 1.461953
      1979 | 1.174632 .1644516 7.14 0.000 .8521775 1.497086
      1980 | 1.235588 .1583881 7.80 0.000 .925023 1.546153
      1981 | 1.214034 .1585018 7.66 0.000 .9032467 1.524822
      1982 | 1.209616 .157564 7.68 0.000 .9006676 1.518565
      1983 | 1.213399 .1583138 7.66 0.000 .9029802 1.523818
      1984 | 1.226054 .1577775 7.77 0.000 .9166864 1.535422
      1985 | 1.252878 .1582265 7.92 0.000 .94263 1.563126
      1986 | -.2748713 .1605161 -1.71 0.087 -.5896086 .039866
      1987 | -.2518984 .1619286 -1.56 0.120 -.5694053 .0656084
      1988 | -.2694671 .1632695 -1.65 0.099 -.5896033 .0506691
      1989 | -.2437034 .1637741 -1.49 0.137 -.564829 .0774222
      1990 | -.2719301 .1631565 -1.67 0.096 -.5918447 .0479844
      1991 | -.2678094 .1657425 -1.62 0.106 -.5927946 .0571758
      1992 | -.2644613 .1688687 -1.57 0.117 -.5955762 .0666536
      1993 | -.2268186 .1775771 -1.28 0.202 -.5750088 .1213717
      1994 | -.2336857 .1871741 -1.25 0.212 -.6006937 .1333223
      1995 | -.1565192 .1842934 -0.85 0.396 -.5178787 .2048403
      1996 | -.0941998 .1831856 -0.51 0.607 -.4533871 .2649876
      1997 | -.0987734 .1705863 -0.58 0.563 -.4332562 .2357094
      1998 | -.153142 .1651962 -0.93 0.354 -.477056 .170772
      1999 | -.1879275 .1673238 -1.12 0.261 -.5160133 .1401583
      2000 | -.2191384 .168636 -1.30 0.194 -.5497971 .1115204
      2001 | -.2982059 .1663436 -1.79 0.073 -.6243697 .0279579
      2002 | -.2929308 .1691806 -1.73 0.083 -.6246573 .0387958
      2003 | -.2265498 .1688181 -1.34 0.180 -.5575655 .1044659
      2004 | -.1615362 .1757443 -0.92 0.358 -.5061328 .1830603
      2005 | -.1664573 .1778879 -0.94 0.349 -.515257 .1823425
      2006 | -.2180559 .1818557 -1.20 0.231 -.5746354 .1385237
      2007 | -.2708258 .1801942 -1.50 0.133 -.6241476 .0824961
      2008 | -.4241269 .1813867 -2.34 0.019 -.7797869 -.0684669
      2009 | -.4862781 .1715074 -2.84 0.005 -.822567 -.1499893
      2010 | -.4239721 .1710789 -2.48 0.013 -.7594209 -.0885234
      2011 | -.4113883 .1736931 -2.37 0.018 -.7519628 -.0708138
      2012 | -.3568736 .1839606 -1.94 0.052 -.7175806 .0038333
      2013 | -.2236058 .2208678 -1.01 0.311 -.6566798 .2094681
      2014 | -.3258896 .2045508 -1.59 0.111 -.7269695 .0751903
      2015 | -.3724304 .2121414 -1.76 0.079 -.7883938 .043533
      2016 | -.3681389 .2272705 -1.62 0.105 -.8137672 .0774894
      2017 | -.4425096 .2373986 -1.86 0.062 -.9079969 .0229777
      2018 | -.4737445 .2381267 -1.99 0.047 -.9406595 -.0068296
      2019 | -.2071411 .2362073 -0.88 0.381 -.6702925 .2560103
      2020 | -.188094 .2496542 -0.75 0.451 -.6776119 .3014238
      2021 | -.1728412 .2453747 -0.70 0.481 -.6539679 .3082855
      2022 | 0 (omitted)
      |
      _cons | -15.03153 1.55446 -9.67 0.000 -18.07949 -11.98357
      -----------------------------------------------------------------------------------------------------------

      C)
      . margins, dydx(c.log_gdp_capita) at(c.log_gdp_capita=($MyMin($Grid)15) dum1986=(0))

      Average marginal effects Number of obs = 3,088
      Model VCE: Robust

      Expression: Linear prediction, predict()
      dy/dx wrt: log_gdp_capita
      1._at: log_gdp_capita = 5.933783
      dum1986 = 0
      2._at: log_gdp_capita = 6.024445
      dum1986 = 0
      3._at: log_gdp_capita = 6.115107
      dum1986 = 0
      4._at: log_gdp_capita = 6.205769
      dum1986 = 0
      5._at: log_gdp_capita = 6.296431
      dum1986 = 0
      6._at: log_gdp_capita = 6.387093
      dum1986 = 0
      7._at: log_gdp_capita = 6.477756
      dum1986 = 0
      8._at: log_gdp_capita = 6.568418
      dum1986 = 0
      9._at: log_gdp_capita = 6.65908
      dum1986 = 0
      10._at: log_gdp_capita = 6.749742
      dum1986 = 0
      11._at: log_gdp_capita = 6.840404
      dum1986 = 0
      12._at: log_gdp_capita = 6.931066
      dum1986 = 0
      13._at: log_gdp_capita = 7.021729
      dum1986 = 0
      14._at: log_gdp_capita = 7.112391
      dum1986 = 0
      15._at: log_gdp_capita = 7.203053
      dum1986 = 0
      16._at: log_gdp_capita = 7.293715
      dum1986 = 0
      17._at: log_gdp_capita = 7.384377
      dum1986 = 0
      18._at: log_gdp_capita = 7.47504
      dum1986 = 0
      19._at: log_gdp_capita = 7.565702
      dum1986 = 0
      20._at: log_gdp_capita = 7.656364
      dum1986 = 0
      21._at: log_gdp_capita = 7.747026
      dum1986 = 0
      22._at: log_gdp_capita = 7.837688
      dum1986 = 0
      23._at: log_gdp_capita = 7.92835
      dum1986 = 0
      24._at: log_gdp_capita = 8.019013
      dum1986 = 0
      25._at: log_gdp_capita = 8.109675
      dum1986 = 0
      26._at: log_gdp_capita = 8.200337
      dum1986 = 0
      27._at: log_gdp_capita = 8.290999
      dum1986 = 0
      28._at: log_gdp_capita = 8.381661
      dum1986 = 0
      29._at: log_gdp_capita = 8.472323
      dum1986 = 0
      30._at: log_gdp_capita = 8.562986
      dum1986 = 0
      31._at: log_gdp_capita = 8.653648
      dum1986 = 0
      32._at: log_gdp_capita = 8.74431
      dum1986 = 0
      33._at: log_gdp_capita = 8.834972
      dum1986 = 0
      34._at: log_gdp_capita = 8.925634
      dum1986 = 0
      35._at: log_gdp_capita = 9.016297
      dum1986 = 0
      36._at: log_gdp_capita = 9.106959
      dum1986 = 0
      37._at: log_gdp_capita = 9.197621
      dum1986 = 0
      38._at: log_gdp_capita = 9.288283
      dum1986 = 0
      39._at: log_gdp_capita = 9.378945
      dum1986 = 0
      40._at: log_gdp_capita = 9.469607
      dum1986 = 0
      41._at: log_gdp_capita = 9.56027
      dum1986 = 0
      42._at: log_gdp_capita = 9.650932
      dum1986 = 0
      43._at: log_gdp_capita = 9.741594
      dum1986 = 0
      44._at: log_gdp_capita = 9.832256
      dum1986 = 0
      45._at: log_gdp_capita = 9.922918
      dum1986 = 0
      46._at: log_gdp_capita = 10.01358
      dum1986 = 0
      47._at: log_gdp_capita = 10.10424
      dum1986 = 0
      48._at: log_gdp_capita = 10.1949
      dum1986 = 0
      49._at: log_gdp_capita = 10.28557
      dum1986 = 0
      50._at: log_gdp_capita = 10.37623
      dum1986 = 0
      51._at: log_gdp_capita = 10.46689
      dum1986 = 0
      52._at: log_gdp_capita = 10.55755
      dum1986 = 0
      53._at: log_gdp_capita = 10.64822
      dum1986 = 0
      54._at: log_gdp_capita = 10.73888
      dum1986 = 0
      55._at: log_gdp_capita = 10.82954
      dum1986 = 0
      56._at: log_gdp_capita = 10.9202
      dum1986 = 0
      57._at: log_gdp_capita = 11.01086
      dum1986 = 0
      58._at: log_gdp_capita = 11.10153
      dum1986 = 0
      59._at: log_gdp_capita = 11.19219
      dum1986 = 0
      60._at: log_gdp_capita = 11.28285
      dum1986 = 0
      61._at: log_gdp_capita = 11.37351
      dum1986 = 0
      62._at: log_gdp_capita = 11.46418
      dum1986 = 0
      63._at: log_gdp_capita = 11.55484
      dum1986 = 0
      64._at: log_gdp_capita = 11.6455
      dum1986 = 0
      65._at: log_gdp_capita = 11.73616
      dum1986 = 0
      66._at: log_gdp_capita = 11.82682
      dum1986 = 0
      67._at: log_gdp_capita = 11.91749
      dum1986 = 0
      68._at: log_gdp_capita = 12.00815
      dum1986 = 0
      69._at: log_gdp_capita = 12.09881
      dum1986 = 0
      70._at: log_gdp_capita = 12.18947
      dum1986 = 0
      71._at: log_gdp_capita = 12.28013
      dum1986 = 0
      72._at: log_gdp_capita = 12.3708
      dum1986 = 0
      73._at: log_gdp_capita = 12.46146
      dum1986 = 0
      74._at: log_gdp_capita = 12.55212
      dum1986 = 0
      75._at: log_gdp_capita = 12.64278
      dum1986 = 0
      76._at: log_gdp_capita = 12.73345
      dum1986 = 0
      77._at: log_gdp_capita = 12.82411
      dum1986 = 0
      78._at: log_gdp_capita = 12.91477
      dum1986 = 0
      79._at: log_gdp_capita = 13.00543
      dum1986 = 0
      80._at: log_gdp_capita = 13.09609
      dum1986 = 0
      81._at: log_gdp_capita = 13.18676
      dum1986 = 0
      82._at: log_gdp_capita = 13.27742
      dum1986 = 0
      83._at: log_gdp_capita = 13.36808
      dum1986 = 0
      84._at: log_gdp_capita = 13.45874
      dum1986 = 0
      85._at: log_gdp_capita = 13.54941
      dum1986 = 0
      86._at: log_gdp_capita = 13.64007
      dum1986 = 0
      87._at: log_gdp_capita = 13.73073
      dum1986 = 0
      88._at: log_gdp_capita = 13.82139
      dum1986 = 0
      89._at: log_gdp_capita = 13.91205
      dum1986 = 0
      90._at: log_gdp_capita = 14.00272
      dum1986 = 0
      91._at: log_gdp_capita = 14.09338
      dum1986 = 0
      92._at: log_gdp_capita = 14.18404
      dum1986 = 0
      93._at: log_gdp_capita = 14.2747
      dum1986 = 0
      94._at: log_gdp_capita = 14.36536
      dum1986 = 0
      95._at: log_gdp_capita = 14.45603
      dum1986 = 0
      96._at: log_gdp_capita = 14.54669
      dum1986 = 0
      97._at: log_gdp_capita = 14.63735
      dum1986 = 0
      98._at: log_gdp_capita = 14.72801
      dum1986 = 0
      99._at: log_gdp_capita = 14.81868
      dum1986 = 0
      100._at: log_gdp_capita = 14.90934
      dum1986 = 0
      101._at: log_gdp_capita = 15
      dum1986 = 0

      --------------------------------------------------------------------------------
      | Delta-method
      | dy/dx std. err. t P>|t| [95% conf. interval]
      ---------------+----------------------------------------------------------------
      log_gdp_capita |
      _at |
      1 | . (not estimable)
      2 | . (not estimable)
      3 | . (not estimable)
      4 | . (not estimable)
      5 | . (not estimable)
      6 | . (not estimable)
      7 | . (not estimable)
      8 | . (not estimable)
      9 | . (not estimable)
      10 | . (not estimable)
      11 | . (not estimable)
      12 | . (not estimable)
      13 | . (not estimable)
      14 | . (not estimable)
      15 | . (not estimable)
      16 | . (not estimable)
      17 | . (not estimable)
      18 | . (not estimable)
      19 | . (not estimable)
      20 | . (not estimable)
      21 | . (not estimable)
      22 | . (not estimable)
      23 | . (not estimable)
      24 | . (not estimable)
      25 | . (not estimable)
      26 | . (not estimable)
      27 | . (not estimable)
      28 | . (not estimable)
      29 | . (not estimable)
      30 | . (not estimable)
      31 | . (not estimable)
      32 | . (not estimable)
      33 | . (not estimable)
      34 | . (not estimable)
      35 | . (not estimable)
      36 | . (not estimable)
      37 | . (not estimable)
      38 | . (not estimable)
      39 | . (not estimable)
      40 | . (not estimable)
      41 | . (not estimable)
      42 | . (not estimable)
      43 | . (not estimable)
      44 | . (not estimable)
      45 | . (not estimable)
      46 | . (not estimable)
      47 | . (not estimable)
      48 | . (not estimable)
      49 | . (not estimable)
      50 | . (not estimable)
      51 | . (not estimable)
      52 | . (not estimable)
      53 | . (not estimable)
      54 | . (not estimable)
      55 | . (not estimable)
      56 | . (not estimable)
      57 | . (not estimable)
      58 | . (not estimable)
      59 | . (not estimable)
      60 | . (not estimable)
      61 | . (not estimable)
      62 | . (not estimable)
      63 | . (not estimable)
      64 | . (not estimable)
      65 | . (not estimable)
      66 | . (not estimable)
      67 | . (not estimable)
      68 | . (not estimable)
      69 | . (not estimable)
      70 | . (not estimable)
      71 | . (not estimable)
      72 | . (not estimable)
      73 | . (not estimable)
      74 | . (not estimable)
      75 | . (not estimable)
      76 | . (not estimable)
      77 | . (not estimable)
      78 | . (not estimable)
      79 | . (not estimable)
      80 | . (not estimable)
      81 | . (not estimable)
      82 | . (not estimable)
      83 | . (not estimable)
      84 | . (not estimable)
      85 | . (not estimable)
      86 | . (not estimable)
      87 | . (not estimable)
      88 | . (not estimable)
      89 | . (not estimable)
      90 | . (not estimable)
      91 | . (not estimable)
      92 | . (not estimable)
      93 | . (not estimable)
      94 | . (not estimable)
      95 | . (not estimable)
      96 | . (not estimable)
      97 | . (not estimable)
      98 | . (not estimable)
      99 | . (not estimable)
      100 | . (not estimable)
      101 | . (not estimable)
      --------------------------------------------------------------------------------

      Comment


      • #4
        Thank you. The problem is now clear. Your variable dum_1986 is colinear with the i.year variables, because dum_1986 is an indicator for the year 1950 through 1985. Because of that colinearity, Stata omitted 2022.year from the analysis (observe: "note: 2022.year omitted because of collinearity.")

        When you have a model which contains colinear variables, the model is unidentified. In order to identify the model, some constraint(s) must be applied. In this case, Stata chose to do this by omitting 2022.year from the calculation. It could just as well have omitted some other year indicator, or it could have omitted dum_1986. And there are many other possibilities. All of these constraints, however, lead to different regression results for the coefficients of the year variables and dum_1986. In other words, in this kind of model, the coefficients of the year variables and dum_1986 are simply artifacts of how the colinearity among them was removed, and are therefore meaningless. That is why -margins- refuses to take you seriously when you try to use dum_1986 in the -margins- command, because it knows from the regression results that dum_1986 is now a meaningless variable in your model.

        Moral of the story: in a two-way fixed effects model, which is what you have here, you must not include any variables that indicate some subset of the years (like dum_1986). If dum_1986 is a key aspect of your research question, the closest alternative is to keep dum_1986 but remove year fixed effects and go with just id level fixed effects. But you cannot have both dum_1986 and the year effects in the model.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          Thank you. The problem is now clear. Your variable dum_1986 is colinear with the i.year variables, because dum_1986 is an indicator for the year 1950 through 1985. Because of that colinearity, Stata omitted 2022.year from the analysis (observe: "note: 2022.year omitted because of collinearity.")

          When you have a model which contains colinear variables, the model is unidentified. In order to identify the model, some constraint(s) must be applied. In this case, Stata chose to do this by omitting 2022.year from the calculation. It could just as well have omitted some other year indicator, or it could have omitted dum_1986. And there are many other possibilities. All of these constraints, however, lead to different regression results for the coefficients of the year variables and dum_1986. In other words, in this kind of model, the coefficients of the year variables and dum_1986 are simply artifacts of how the colinearity among them was removed, and are therefore meaningless. That is why -margins- refuses to take you seriously when you try to use dum_1986 in the -margins- command, because it knows from the regression results that dum_1986 is now a meaningless variable in your model.

          Moral of the story: in a two-way fixed effects model, which is what you have here, you must not include any variables that indicate some subset of the years (like dum_1986). If dum_1986 is a key aspect of your research question, the closest alternative is to keep dum_1986 but remove year fixed effects and go with just id level fixed effects. But you cannot have both dum_1986 and the year effects in the model.
          Thank you so much, that makes sense! I'll try to figure it out.

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            Thank you. The problem is now clear. Your variable dum_1986 is colinear with the i.year variables, because dum_1986 is an indicator for the year 1950 through 1985. Because of that colinearity, Stata omitted 2022.year from the analysis (observe: "note: 2022.year omitted because of collinearity.")

            When you have a model which contains colinear variables, the model is unidentified. In order to identify the model, some constraint(s) must be applied. In this case, Stata chose to do this by omitting 2022.year from the calculation. It could just as well have omitted some other year indicator, or it could have omitted dum_1986. And there are many other possibilities. All of these constraints, however, lead to different regression results for the coefficients of the year variables and dum_1986. In other words, in this kind of model, the coefficients of the year variables and dum_1986 are simply artifacts of how the colinearity among them was removed, and are therefore meaningless. That is why -margins- refuses to take you seriously when you try to use dum_1986 in the -margins- command, because it knows from the regression results that dum_1986 is now a meaningless variable in your model.

            Moral of the story: in a two-way fixed effects model, which is what you have here, you must not include any variables that indicate some subset of the years (like dum_1986). If dum_1986 is a key aspect of your research question, the closest alternative is to keep dum_1986 but remove year fixed effects and go with just id level fixed effects. But you cannot have both dum_1986 and the year effects in the model.
            I got one more question, hope you can help.

            The things about calculating the margins is that I want to calculate one version where it only uses the log_GDP and the squared log_GDP (which is when dum1986 is 0) and another version there it takes the log_GDP + the interaction term and the same for the squared model - so I can get the effect of GDP before 1986 and from and after 1986 separated.

            Is the moral still the same as before or is there a way around this?

            Comment


            • #7
              The moral is still the same and there is no way around it: it's linear algebra. You can get what you want by omitting the i.year variables from the model.

              Comment

              Working...
              X