Announcement

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

  • Margins for panel

    Dear all,

    I am having a macro panel for a larger period of years (1945- 2020) and for large number of countries with the solid macro variables, dummies, categorical variables and some custom quality indicators, expressed in
    percentage, which you can see in the
    data example below for shorter time length and less countries . According to my model, indicators definitely determine macro variables. My main model is :
    ΔY= (a-1) + b1yI,t-1 + b2TytI,-1 +b3T2ytI,-1 +Zi,t + Di,t + e,it,
    Where Y is the dependent variable of interest, Z a set of control variables, and D a set of dummy variables

    In sort, I fit a model with polynomial terms, such as

    y = a*x^2 + b*x + ...
    So, if the coefficient a is negative then I have a U-shape curve facing downwards that I will be able to locate the maximum of y when x -b/2a. I try to achieve that by -margins-,

    regress Dgdp2 cpi u industry dummy1 dummy2 dummy3 c.indicator1##c.indicator1, vce(robust)
    margins, at(indicator1=(-16(1)48)) plot

    nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])

    However, the -regress- command with -vce(robust)- does not implement a panel estimation. Due to the reason that I cannot run a panel estimation for each id and year combination, each id, or each year xt- estimations are no longer available to my dataset. -regress- just pools observations together, treating them cross-sectional if you run it for
    each id or each year when there are sufficient observations. . I tried with other panel commands without success. I am insisting to that because I want to be able to use -margins- to visualize the quadratic relationship (U-shaped curve)

    I would appreciate any help you can provide
    Thank you in advance

    Best.
    Mario Ferri!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(id ts) str97 country float(indicator1 cpi u gdp industry ka gw dummy1 dumm2 dummy3 Dgdp2)
    1 1981 "Australia"       20.613514  9.487666  5.78  4.540717e+11 43.42793 .41687185   .20370182 0 0 0  146663.34
    1 1982 "Australia"       20.613514  11.35182  7.16  4.691852e+11 43.09072 .41687185  -.15889087 0 0 0  151135.19
    1 1983 "Australia"        6.500914  10.03891  9.96  4.587671e+11 41.44292 .41687185  .027918227 1 1 1 -104181.27
    1 1984 "Australia"       3.3282194  3.960396  8.99  4.797846e+11 44.21151 .47684005   1.4786447 1 0 0  210174.94
    1 1985 "Australia"             5.8  6.734694  8.26    5.0497e+11 46.74982  .8200954   -.4968416 0 0 0   251854.5
    1 1986 "Australia"             5.8   9.05035  8.08  5.253583e+11 46.31632  .8800636  -.23686917 0 0 0  203883.16
    1 1987 "Australia"        6.556594  8.533022  8.11  5.387611e+11 49.62373  .9400318   .18794964 1 0 0     134028
    1 1988 "Australia"             7.5   7.21594  7.23  569704251392 53.17501         1    .4695499 0 0 0   309431.2
    1 1989 "Australia"             7.5  7.533903  6.18  5.917015e+11 54.96535         1   .03558734 0 0 0  219972.23
    1 1990 "Australia"       10.999176  7.333022  6.93  612831133696 56.63783         1   .06843487 1 1 1   211296.6
    1 1991 "Australia"            12.2  3.176675  9.58  6.103932e+11 56.07949         1    1.616588 0 0 0  -24379.39
    1 1992 "Australia"            12.2 1.0122311 10.73  6.129091e+11 56.31247         1      1.9267 0 0 0   25159.27
    1 1993 "Australia"       17.553352 1.7536534 10.87  6.376088e+11 58.00952         1  -.55177194 1 1 1  246996.67
    1 1994 "Australia"           19.11 1.9696348  9.72  6.630105e+11 60.82281         1  .007553967 0 0 0  254016.88
    1 1995 "Australia"           19.11 4.6277666  8.47  6.884552e+11 62.44015         1   -.5324481 0 0 0   254446.8
    1 1996 "Australia"       15.414823 2.6153846  8.51  7.151575e+11 64.93562  .9400318     .980418 1 1 1  267023.16
    1 1997 "Australia"          14.538 .22488755  8.36  7.435245e+11 65.80802  .8800636   10.272155 0 0 0  283669.97
    1 1998 "Australia"       17.287497  .8601346  7.68  7.775533e+11  67.9767  .8200954   -.7689896 1 0 0   340288.5
    1 1999 "Australia"       28.634005 1.4831294  6.87  8.170032e+11 68.75488  .7601272   -.3804706 0 0 0   394499.2
    1 2000 "Australia"          28.634  4.457435  6.28  8.491371e+11 72.54832   .700159   -.6822261 0 0 0  321338.75
    2 1981 "Austria"                 2  6.803042  2.06  2.080323e+11 36.20454   .700159    -.200444 0 0 0  -3006.136
    2 1982 "Austria"                 2  5.436031  3.35  212216348672 35.98919   .700159   .20921445 0 0 0   41840.48
    2 1983 "Austria"         1.0946958 3.3391645  4.11  218525728768 36.29808   .700159    .5968089 1 1 1    63093.8
    2 1984 "Austria"          .5089108  5.663186   3.8  2.186378e+11 38.19626   .700159  -.44796655 0 0 0  1120.5017
    2 1985 "Austria"          .5089108  3.189517   3.6  224100843520 39.99393   .700159     .823105 0 0 0   54630.64
    2 1986 "Austria"           .561659 1.7054446  3.12  2.292583e+11 40.40985   .700159    1.638252 0 0 0   51574.38
    2 1987 "Austria"          12.24376 1.4019527  3.79  2.323697e+11 40.80097   .700159   .50470144 0 0 0    31114.2
    2 1988 "Austria"         12.920382  1.915717  3.55  2.400283e+11 42.56515   .700159  -.23894365 0 0 0   76586.19
    2 1989 "Austria"         12.920382 2.5683484  3.14  2.493584e+11 45.09982   .700159  -.26313263 0 0 0   93300.82
    2 1990 "Austria"         12.619598  3.261872  3.25  260194631680 48.31841   .700159 -.008617969 1 0 0   108362.3
    2 1991 "Austria"               5.1  3.337427  3.42  269149552640 49.15068  .7601272  .012651701 0 0 0   89549.21
    2 1992 "Austria"               5.1  4.020848  3.59  274784272384 48.56378  .8200954  -.10854957 0 0 0    56347.2
    2 1993 "Austria"               5.1  3.631785  4.25  276231847936  47.7724  .8800636   .03468369 0 0 0  14475.756
    2 1994 "Austria"          5.248024 2.9534094  3.54  282867269632 49.68189  .9400318   .26526877 1 0 0   66354.22
    2 1995 "Austria"          7.179246 2.2433662  4.35  290414133248 52.20742         1    .7674453 1 0 0   75468.63
    2 1996 "Austria"         17.413164 1.8609712  5.28  2.972375e+11  52.7208         1   .16558754 0 0 0   68233.79
    2 1997 "Austria"         17.166555 1.3059785  5.15  303460483072 56.07532         1   .13704391 0 0 0   62229.71
    2 1998 "Austria"         17.155384  .9224672  5.52  314328678400  60.6142         1    .4728145 0 0 0  108681.95
    2 1999 "Austria"          13.81384 .56899375   4.7  325507252224 64.24256         1    .5897323 1 0 0  111785.73
    2 2000 "Austria"          3.427717  2.344863  4.69  3.364955e+11 70.08217         1   -.7848026 0 0 0  109882.24
    3 1981 "France"          1.6382614 13.314405  7.54 1.4984657e+12 79.29216 .41687185   -.9999912 1 0 0   158494.9
    3 1982 "France"          -4.953055 11.978472   8.2 1.5360083e+12 78.65401 .16434518    .0278443 0 0 0   375425.6
    3 1983 "France"          -4.953055  9.459548  7.92  1.555068e+12 78.70774 .41687185   .17290956 0 0 0  190597.03
    3 1984 "France"         -4.7091045  7.673803  9.53 1.5786074e+12 80.06466 .41687185   .13435355 0 0 0  235394.83
    3 1985 "France"               -4.4    5.8311 10.26  1.604225e+12 80.26139 .41687185   .34410325 0 0 0  256173.67
    3 1986 "France"           17.15525  2.538526 10.23   1.64172e+12 82.29907 .41687185   305361.44 1 1 1   374951.1
    3 1987 "France"          23.033955  3.288898 10.74 1.6837792e+12 83.73698 .41687185  -.09669671 0 0 0     420593
    3 1988 "France"           9.400383  2.700815 10.18 1.7636432e+12 86.72044 .41687185   .26424965 1 0 0   798640.1
    3 1989 "France"                1.6  3.498302  9.62 1.8402534e+12 89.72697 .41687185   -.2393705 0 0 0   766101.4
    3 1990 "France"                1.6 3.1942835  9.36  1.894061e+12 91.03416 .47684005  -.08574203 0 0 0  538078.06
    3 1991 "France"                1.6  3.213407  9.13 1.9139143e+12 90.95167 .53680825    -.999992 0 0 0  198530.83
    3 1992 "France"                1.6 2.3637605 10.21 1.9445244e+12 90.21667  .5967765       .4548 0 0 0  306101.63
    3 1993 "France"           6.996447 2.1044629 11.32    1.9323e+12    86.85  .9400318  .022043044 1 1 1  -122245.6
    3 1994 "France"            8.69136 1.6555153 12.59   1.97787e+12 90.03333         1    .2997584 0 0 0     455702
    3 1995 "France"            8.69136 1.7964814 11.84 2.0195377e+12 92.69833         1   .05559472 0 0 0   416676.6
    3 1996 "France"            8.69136 1.9828837 12.37 2.0480737e+12    93.46         1   118525.52 0 0 0  285359.47
    3 1997 "France"           5.041234  1.203943 12.57  2.095923e+12 97.54333         1    .4296218 1 1 1   478491.4
    3 1998 "France"           2.364474  .6511269 12.07 2.1711383e+12 101.5933         1    .8784832 0 0 0   752155.4
    3 1999 "France"           2.364474  .5371416 11.98  2.245421e+12  104.295         1    .1964599 0 0 0   742825.7
    3 2000 "France"           2.364474   1.67596 10.22 2.3335238e+12 108.6008         1   -.9999971 0 0 0   881029.3
    4 1981 "United Kingdom"       18.6 11.876627  10.4 1.2182697e+12 77.52663  .8800636    .3102416 0 0 0  -96729.83
    4 1982 "United Kingdom"       18.6  8.598864  10.9 1.2425728e+12  77.7118  .9400318     .230822 0 0 0   243031.1
    4 1983 "United Kingdom"  18.766483 4.6093035 11.09 1.2950324e+12 79.73109         1    .6651978 1 0 0     524596
    4 1984 "United Kingdom"       18.9  4.960711  10.9  1.324418e+12 80.24253         1  -.12341004 0 0 0  293856.88
    4 1985 "United Kingdom"       18.9  6.071394 11.49 1.3793472e+12 84.36929         1  -.16183244 0 0 0   549291.3
    4 1986 "United Kingdom"       18.9 3.4276094 11.51 1.4228014e+12 86.21222         1   1.1283993 0 0 0   434541.7
    4 1987 "United Kingdom"  17.745354 4.1489224 11.02 1.4995292e+12 89.77464         1 -.015180643 1 0 0   767278.4
    4 1988 "United Kingdom"     16.809 4.1553516  9.01 1.5854885e+12 94.41283         1   .18605655 0 0 0   859592.4
    4 1989 "United Kingdom"     16.809  5.760249  7.41  1.626356e+12 96.38803         1  -.27347788 0 0 0   408675.9
    4 1990 "United Kingdom"     16.809  8.063461  6.97 1.6382895e+12 96.41448         1    83413.91 0 0 0   119334.5
    4 1991 "United Kingdom"     16.809  7.461783  8.55 1.6202173e+12  93.1948         1   .09337864 0 0 0  -180722.1
    4 1992 "United Kingdom"  13.403038 4.5915494  9.78 1.6267156e+12 93.60826         1    .6429237 1 1 1   64982.88
    4 1993 "United Kingdom"       12.1  2.558578 10.35  1.667218e+12 95.62276         1   -.9999845 0 0 0   405025.6
    4 1994 "United Kingdom"       12.1 2.2190125  9.65 1.7313395e+12  100.681         1   123614.65 0 0 0   641213.4
    4 1995 "United Kingdom"       12.1  2.697495  8.69 1.7751713e+12 102.4492         1  -.13095939 0 0 0   438317.9
    4 1996 "United Kingdom"       12.1  2.851782  8.19 1.8194017e+12 103.8479         1 -.033561174 0 0 0   442303.8
    4 1997 "United Kingdom"   5.227907  2.201143  7.07 1.9099222e+12 106.6101         1    .4296572 1 1 1   905205.5
    4 1998 "United Kingdom"      1.806 1.8205616   6.2 1.9807378e+12 107.4667         1   .27417862 0 0 0   708155.8
    4 1999 "United Kingdom"      1.806 1.7529508  6.04  2.046007e+12  108.652         1  .024280345 0 0 0   652692.7
    4 2000 "United Kingdom"      1.806 1.1829562  5.56 2.1177446e+12 110.4949         1    .3995405 0 0 0   717375.4
    5 1981 "United States"    7.720604 10.334715   7.6  6.661146e+12 50.72995         1    .4146612 0 0 0  1648576.4
    5 1982 "United States"         8.3  6.131427   9.7  6.541054e+12 48.11071         1    .6862257 1 0 0 -1200923.6
    5 1983 "United States"         8.3  3.212435   9.6  6.840891e+12 49.41756         1    .9804647 0 0 0  2998371.5
    5 1984 "United States"         8.3 4.3005357   7.5   7.33594e+12 53.80223         1   -.1878409 1 0 0    4950495
    5 1985 "United States"    16.16676  3.545644   7.2  7.641824e+12 54.46311         1   -.8751099 0 0 0  3058832.5
    5 1986 "United States"        16.6 1.8980477     7  7.906433e+12 55.01276         1   17.963144 1 0 0    2646097
    5 1987 "United States"        16.6  3.664563   6.2  8.179962e+12 57.87624         1     -.44877 0 0 0    2735289
    5 1988 "United States"        16.6  4.077741   5.5  8.521643e+12 60.88547         1  -.05447189 1 0 0    3416806
    5 1989 "United States"   14.988736  4.827003   5.3  8.834614e+12 61.43758         1   -.1320547 0 0 0    3129706
    5 1990 "United States"        14.9  5.397956   5.6  9.001231e+12 62.05701         1  -.08746292 1 0 0  1666176.8
    5 1991 "United States"        14.9  4.234964   6.8  8.991487e+12 61.15007         1    .2589748 0 0 0  -97444.16
    5 1992 "United States"        14.9 3.0288196   7.5  9.308206e+12 62.92408         1   13.807285 1 0 0    3167192
    5 1993 "United States"    .0375137  2.951657   6.9  9.564447e+12 64.99349         1   .04719354 0 0 0    2562405
    5 1994 "United States"       -.781  2.607442  6.12  9.949782e+12 68.42391         1   .17382646 1 0 0  3853359.5
    5 1995 "United States"       -.781   2.80542  5.65 1.0216863e+13 71.58787         1 -.032830253 0 0 0    2670807
    5 1996 "United States"       -.781  2.931204  5.45 1.0602295e+13 74.84686         1  -.02388202 1 0 0    3854314
    5 1997 "United States"   1.3458682 2.3376899     5 1.1073802e+13 80.20259         1   .29131374 0 0 0  4715079.5
    5 1998 "United States"       1.463  1.552279  4.51 1.1570064e+13 84.89986         1   .55129653 1 0 0  4962616.5
    5 1999 "United States"       1.463 2.1880271  4.22 1.2120017e+13 88.64145         1   -.9274685 0 0 0    5499530
    5 2000 "United States"       1.463  3.376857  3.99  1.262027e+13 92.05371         1    5.664342 1 0 0    5002515
    end
    Last edited by Mario Ferri; 22 Feb 2022, 15:33.

  • #2
    Mario:
    why nit ussing -xtgls- or -xtregar- estimators?
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Mario:
      why nit ussing -xtgls- or -xtregar- estimators?
      I am having a quadratic relation there and not sure if I am going to lose the nice quadratic results I am getting. I am expecting a U shape curve. Given my large T in the real data sample, my T>N, the strange thing is that depending on which command I take I am getting a different U shape curve, convex or concave, which makes me confused

      Also, I am concerned about heterogeneity and autocorrelation in the panel, thus the vce(robust) option to implement Huber-White sandwich estimator to take care of heteroscedasticity.
      My initial idea was to include also one lag, not sure if this is correct or appropriate given my ΔY already in the left-hand side and not sure how to do it.

      Thank you for any input you can provide!

      Comment


      • #4
        Originally posted by Mario Ferri View Post

        I am having a quadratic relation there and not sure if I am going to lose the nice quadratic results I am getting. I am expecting a U shape curve. Given my large T in the real data sample, my T>N, the strange thing is that depending on which command I take I am getting a different U shape curve, convex or concave, which makes me confused

        Also, I am concerned about heterogeneity and autocorrelation in the panel, thus the vce(robust) option to implement Huber-White sandwich estimator to take care of heteroscedasticity.
        My initial idea was to include also one lag, not sure if this is correct or appropriate given my ΔY already in the left-hand side and not sure how to do it.

        Thank you for any input you can provide!
        @Carlo Lazzaro I 've tested both. With xtreg I get a coefficient of almost 5 and with xtregar a coefficient of almost 12. Which one to choose?

        Comment


        • #5
          Mario:
          different estimators produce different results, no wonder about that.
          As per FAQ, posting what you typed and what Stata gave you back via CODE delimiters would help interested listers in replying more positively. Thanks.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment


          • #6
            Originally posted by Carlo Lazzaro View Post
            Mario:
            different estimators produce different results, no wonder about that.
            As per FAQ, posting what you typed and what Stata gave you back via CODE delimiters would help interested listers in replying more positively. Thanks.

            I first rescaled and create some variables
            generate Dgdp2 = Dgdp/100000
            gen growth= D.Dgdp2/L.Dgdp2


            For xtreg I get a convex curve.

            qui xtreg Dgdp2 cpi u industry ka gw dummy1 dummy2 dummy3 c.indicator1##c.indicator1, vce(robust)


            nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])
            qui margins, at(indicator1=(-5(1)29))

            marginsplot, noci xline(`=-_b[indicator1]/(2*_b[indicator1#indicator1])')


            For xtregar I get a concave curve

            xtregar Dgdp2 cpi u industry ka gw dummy1 dummy2 dummy3 c.indicator1##c.indicator1, fe


            nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])
            qui margins, at(indicator1=(-5(1)29))

            marginsplot, noci xline(`=-_b[indicator1]/(2*_b[indicator1#indicator1])')






            It happened to get both convex curves with the full sample, or when I used growth as the dependent variable. With different coefficients. In some cases that contradicts the standard theory, It should be concave instead of convex. What is the best way to go here?
            NB coefficients values are important here
            Last edited by Mario Ferri; 23 Feb 2022, 07:27.

            Comment


            • #7
              Carlo Lazzaro
              Here is the outcome I forgot to post. . I used growth as the depended variable; I was expecting a concave curve.

              xterg

              nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])

              _nl_1: -_b[indicator1]/(2*_b[indicator1#indicator1])

              ------------------------------------------------------------------------------
              growth | Coef. Std. Err. z P>|z| [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              _nl_1 | 6.068816 4.251735 1.43 0.153 -2.264432 14.40206
              ------------------------------------------------------------------------------




              Click image for larger version

Name:	xtreg.jpg
Views:	1
Size:	38.6 KB
ID:	1651614




              And here the xtregar

              nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])

              _nl_1: -_b[indicator1]/(2*_b[indicator1#indicator1])

              ------------------------------------------------------------------------------
              growth | Coef. Std. Err. z P>|z| [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              _nl_1 | 8.359921 8.905576 0.94 0.348 -9.094688 25.81453
              ------------------------------------------------------------------------------

              Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	41.2 KB
ID:	1651615



              In the full sample differences in the coefficients between those two are much larger (i.e 4 vs 12) and it is not always the same U shape curve .

              Comment


              • #8
                Mario:
                if you are dealing with a T>N panel dataset, -xtreg- is not the way to go.
                The viable options are -xtgls- (that doe not allow fixed effect) and -xtregar- (that allows both fixed and random effect specification).
                Kind regards,
                Carlo
                (StataNow 18.5)

                Comment


                • #9
                  Originally posted by Carlo Lazzaro View Post
                  Mario:
                  if you are dealing with a T>N panel dataset, -xtreg- is not the way to go.
                  The viable options are -xtgls- (that doe not allow fixed effect) and -xtregar- (that allows both fixed and random effect specification).

                  Cerlo,
                  See this https://www.statalist.org/forums/for...75#post1569075

                  I am having a Yt-Yt-1 as depended variable. I guess this is not the case Jeff Wooldridge is referring to in his post.

                  Also, please kindly, if you have the time, check why the margins in #1 I am getting a convex instead of a concave u shape curve. My understanding is that I have mistaken the minimization/ maximization in the margins, but can't find the right way for a quadratic.

                  Mathematically ,it will be for what value of X, Y is maximized

                  Comment

                  Working...
                  X