Announcement

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

  • Dear Elif Cengen,

    Two periods is certainly not enough and I am surprised that the estimates vary across quantiles. Can you please contact me by email so that we can explore what is going on? I can then post the finding here.

    Best wishes,

    Joao

    Comment


    • Hi all,
      According to the help file, one can access the coefficient vectors and covariance matrices from running an estimation with multiple quantiles simulatanously, i.e. with e(b_90) for the 9th decile point estimate. This does not seem to be the case (see results below). Or what am I doing wrong? The stored vector is empty (showed below). If this could be fixed, numerous problems could be solved that I am running into (elucidated here): This seems to be a general problem when estimating anything with more than one quantile, although in the help file, it is stated that one can do this.

      " If multiple quantiles are estimated, xtqreg also saves b, V, and q for each quantile with names of the form (for the first quartile) e(b_25), e(V_25), and e(q_25). In this case, the matrices e(b), e(V), and e(q) contain the results for the last estimated quantile."

      For example:

      When estimating multiple quantiles, I cannot access the coefficient vector of anything apart from the last estimated quantile. Why is this the case? This is making my life a bit hard trying to make tables and do bootstrapping while estimaing quantiles simultaneously. Is there a way around this?
      Below is code and results, not bootstrapping for time's sake (commented out), but to show the problem I am having. Otherwise I have to estimate each quantile separately with a bootstrap that takes a long time for me.

      Also, it would be fantastic if when i store results using esttab or eststo: xtqreg .... with the "ls" option, that the location and scale functions can be automatically tabulated as well. At the moment I can only get the Quantile point estimate in a table automatically (esttab after storing results only gives the point estimate and not location and scale functions) and have to make workarounds that make it somewhat tedious to get a publishable table in due time. If anyone has a solution here I would be very thankful.

      Ideally, after estimating multiple quantiles simultaneously, e.g.

      #
      bs, cluster(id) idcluster(newid) group(id) rep(200): xtqreg logTotalWealth MV_shock_sc MV_trend_sc IND_MV_shock_sc IND_MV_trend_sc GDP_growth imf24 imf33 i.Year Age Age_sq, id(id) ls q(0.1(0.2)0.9)

      and then running esttab after saving, I should get location, scale, and the point estimates all in one table, and these should be saved.
      But if I do this, it would only give the last estimated quantile, and no other results. This seems to be related to the above issue of only accessing the last estimated quantile point estimate (here 0.9) when estimating mulitple quantiles. Also, then I could do a JK Bias correction after saving the different b_quantile vectors, covariance matrices, and quantile errors from running an estimation with multiple quantiles.
      The main point being, I then only need to run one bootstrap loop which already takes a long time, and not one for each quantile, and then no longer copy and paste my results...

      Thanks in advance,
      Michael

      Last edited by Michael Haylock; 15 Sep 2020, 10:21.

      Comment


      • Post deleted
        Last edited by Michael Haylock; 15 Sep 2020, 10:17.

        Comment


        • Code:
          . /*bs, cluster(id) idcluster(newid) group(id) rep(200):*/ xtqreg logTotalCompensation MV_shock_sc MV_trend_sc IND_MV_shock_sc IND_MV_trend_sc GDP_growth imf24 imf33 i.Year Age Age_sq
          > , id(id) ls quantile(0.1(0.2)0.9)
          
          
          
          MM-QR regression results
          Number of obs = 25706
          
          Location parameters
          (Std. Err. adjusted for 6,946 clusters in id)
          ---------------------------------------------------------------------------------
          | Robust
          logTotalCompe~n | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .0046484 .0012089 3.85 0.000 .0022785 .0070184
          MV_trend_sc | .0050125 .0021142 2.37 0.018 .0008681 .009157
          IND_MV_shock_sc | .0007126 .0021668 0.33 0.742 -.0035349 .0049602
          IND_MV_trend_sc | .0014187 .0020131 0.70 0.481 -.0025277 .005365
          GDP_growth | .010524 .0071083 1.48 0.139 -.0034104 .0244584
          imf24 | .0000215 3.04e-06 7.08 0.000 .0000156 .0000275
          imf33 | .0246066 .0105961 2.32 0.020 .0038351 .0453782
          |
          Year |
          2003 | .1759501 .1707837 1.03 0.303 -.1588381 .5107382
          2004 | .0283583 .1895973 0.15 0.881 -.3433103 .4000269
          2005 | .2930514 .2371676 1.24 0.217 -.1718695 .7579723
          2006 | .5028077 .2801 1.80 0.073 -.0462739 1.051889
          2007 | .6271276 .3280158 1.91 0.056 -.0158837 1.270139
          2008 | .4645995 .3781433 1.23 0.219 -.2766771 1.205876
          2009 | .8845965 .4259698 2.08 0.038 .0495654 1.719628
          2010 | .9456714 .4742507 1.99 0.046 .0159951 1.875348
          2011 | .9454018 .5287649 1.79 0.074 -.091139 1.981943
          2012 | 1.115021 .5797992 1.92 0.055 -.0215626 2.251605
          2013 | 1.282268 .6343921 2.02 0.043 .0386653 2.52587
          |
          Age | .1296837 .059011 2.20 0.028 .0140041 .2453634
          Age_sq | -.0018104 .0002101 -8.62 0.000 -.0022223 -.0013985
          _cons | 3.142591 2.537942 1.24 0.216 -1.832551 8.117732
          ---------------------------------------------------------------------------------
          Scale parameters
          (Std. Err. adjusted for 6,946 clusters in id)
          ---------------------------------------------------------------------------------
          | Robust
          | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | -.0014445 .0005711 -2.53 0.011 -.0025641 -.0003249
          MV_trend_sc | .0024466 .0009685 2.53 0.012 .000548 .0043452
          IND_MV_shock_sc | -.0008285 .0010047 -0.82 0.410 -.0027979 .001141
          IND_MV_trend_sc | -.0010953 .0009218 -1.19 0.235 -.0029023 .0007117
          GDP_growth | -.0061733 .0032435 -1.90 0.057 -.0125316 .0001849
          imf24 | 2.87e-06 1.45e-06 1.98 0.048 2.49e-08 5.71e-06
          imf33 | .0069888 .0048692 1.44 0.151 -.0025563 .016534
          |
          Year |
          2003 | .1694704 .0988755 1.71 0.087 -.0243558 .3632967
          2004 | .0225159 .0746856 0.30 0.763 -.1238908 .1689225
          2005 | .1613661 .122404 1.32 0.187 -.0785832 .4013153
          2006 | .1399702 .1411914 0.99 0.322 -.1368081 .4167485
          2007 | .0983096 .1628371 0.60 0.546 -.2209008 .41752
          2008 | .0389999 .1855849 0.21 0.834 -.3248033 .402803
          2009 | .0453703 .2072373 0.22 0.827 -.3608781 .4516187
          2010 | .0520061 .2288973 0.23 0.820 -.3967026 .5007149
          2011 | .0061091 .2540092 0.02 0.981 -.4918267 .5040448
          2012 | .0059601 .278116 0.02 0.983 -.5392322 .5511524
          2013 | .0281614 .3025727 0.09 0.926 -.5649737 .6212964
          |
          Age | -.0444984 .0275973 -1.61 0.107 -.0985976 .0096008
          Age_sq | .0004467 .0000967 4.62 0.000 .0002571 .0006363
          _cons | 1.175088 1.192076 0.99 0.324 -1.161745 3.511921
          ---------------------------------------------------------------------------------
          
          WARNING: some fitted values of the scale function are negative
          .1 Quantile regression
          ---------------------------------------------------------------------------------
          | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .006878 .0145377 0.47 0.636 -.0216155 .0353714
          MV_trend_sc | .0012363 .0184588 0.07 0.947 -.0349423 .0374148
          IND_MV_shock_sc | .0019914 .0236675 0.08 0.933 -.0443962 .0483789
          IND_MV_trend_sc | .0031092 .0203877 0.15 0.879 -.0368499 .0430683
          GDP_growth | .0200524 .0794101 0.25 0.801 -.1355886 .1756933
          imf24 | .0000171 .0000292 0.59 0.558 -.0000401 .0000743
          imf33 | .0138196 .1088064 0.13 0.899 -.1994371 .2270762
          |
          Year |
          2003 | -.0856229 2.414779 -0.04 0.972 -4.818504 4.647258
          2004 | -.0063943 2.781438 -0.00 0.998 -5.457912 5.445124
          2005 | .0439873 3.247157 0.01 0.989 -6.320324 6.408298
          2006 | .2867675 3.608065 0.08 0.937 -6.784909 7.358444
          2007 | .4753894 4.033332 0.12 0.906 -7.429797 8.380575
          2008 | .4044042 4.486745 0.09 0.928 -8.389454 9.198262
          2009 | .8145687 4.937671 0.16 0.869 -8.863088 10.49223
          2010 | .8654014 5.41444 0.16 0.873 -9.746707 11.47751
          2011 | .9359726 5.945422 0.16 0.875 -10.71684 12.58879
          2012 | 1.105822 6.454042 0.17 0.864 -11.54387 13.75551
          2013 | 1.238801 6.9955 0.18 0.859 -12.47213 14.94973
          |
          Age | .1983658 .609973 0.33 0.745 -.9971592 1.393891
          Age_sq | -.0024998 .0018698 -1.34 0.181 -.0061646 .0011649
          ---------------------------------------------------------------------------------
          
          .3 Quantile regression
          ---------------------------------------------------------------------------------
          | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .0058171 .0101092 0.58 0.565 -.0139966 .0256308
          MV_trend_sc | .0030331 .0128358 0.24 0.813 -.0221247 .0281908
          IND_MV_shock_sc | .0013829 .0164578 0.08 0.933 -.0308738 .0336397
          IND_MV_trend_sc | .0023048 .0141771 0.16 0.871 -.0254818 .0300915
          GDP_growth | .0155187 .0552199 0.28 0.779 -.0927104 .1237477
          imf24 | .0000192 .0000203 0.95 0.344 -.0000206 .000059
          imf33 | .0189522 .0756614 0.25 0.802 -.1293415 .1672458
          |
          Year |
          2003 | .0388366 1.67918 0.02 0.982 -3.252296 3.329969
          2004 | .0101414 1.934145 0.01 0.996 -3.780713 3.800995
          2005 | .1624949 2.257995 0.07 0.943 -4.263095 4.588085
          2006 | .3895619 2.508962 0.16 0.877 -4.527912 5.307036
          2007 | .5475882 2.804682 0.20 0.845 -4.949488 6.044664
          2008 | .4330458 3.119974 0.14 0.890 -5.681991 6.548083
          2009 | .8478888 3.433537 0.25 0.805 -5.88172 7.577498
          2010 | .9035948 3.765071 0.24 0.810 -6.475809 8.282999
          2011 | .9404591 4.134303 0.23 0.820 -7.162626 9.043545
          2012 | 1.110199 4.487985 0.25 0.805 -7.68609 9.906488
          2013 | 1.259483 4.864502 0.26 0.796 -8.274766 10.79373
          |
          Age | .1656861 .4241608 0.39 0.696 -.6656539 .997026
          Age_sq | -.0021718 .0013002 -1.67 0.095 -.0047202 .0003766
          ---------------------------------------------------------------------------------
          
          .5 Quantile regression
          ---------------------------------------------------------------------------------
          | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .0045895 .0104258 0.44 0.660 -.0158447 .0250236
          MV_trend_sc | .0051125 .0132378 0.39 0.699 -.0208332 .0310581
          IND_MV_shock_sc | .0006788 .0169732 0.04 0.968 -.032588 .0339456
          IND_MV_trend_sc | .0013739 .014621 0.09 0.925 -.0272828 .0300307
          GDP_growth | .0102719 .0569491 0.18 0.857 -.1013462 .12189
          imf24 | .0000217 .0000209 1.03 0.301 -.0000194 .0000627
          imf33 | .0248921 .0780306 0.32 0.750 -.1280451 .1778293
          |
          Year |
          2003 | .1828716 1.731761 0.11 0.916 -3.211318 3.577061
          2004 | .0292779 1.994708 0.01 0.988 -3.880278 3.938834
          2005 | .299642 2.3287 0.13 0.898 -4.264527 4.863811
          2006 | .5085244 2.587525 0.20 0.844 -4.562931 5.579979
          2007 | .6311428 2.892505 0.22 0.827 -5.038062 6.300348
          2008 | .4661923 3.217669 0.14 0.885 -5.840323 6.772707
          2009 | .8864495 3.54105 0.25 0.802 -6.053882 7.826781
          2010 | .9477955 3.882966 0.24 0.807 -6.662678 8.558269
          2011 | .9456513 4.263759 0.22 0.824 -7.411163 9.302466
          2012 | 1.115264 4.628516 0.24 0.810 -7.95646 10.18699
          2013 | 1.283418 5.016823 0.26 0.798 -8.549374 11.11621
          |
          Age | .1278663 .4374429 0.29 0.770 -.729506 .9852386
          Age_sq | -.0017921 .001341 -1.34 0.181 -.0044204 .0008361
          ---------------------------------------------------------------------------------
          
          .7 Quantile regression
          ---------------------------------------------------------------------------------
          | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .0035007 .0152866 0.23 0.819 -.0264604 .0334619
          MV_trend_sc | .0069565 .0194096 0.36 0.720 -.0310856 .0449985
          IND_MV_shock_sc | .0000544 .0248866 0.00 0.998 -.0487226 .0488313
          IND_MV_trend_sc | .0005484 .0214379 0.03 0.980 -.041469 .0425658
          GDP_growth | .005619 .0835005 0.07 0.946 -.1580389 .1692769
          imf24 | .0000238 .0000307 0.78 0.438 -.0000364 .000084
          imf33 | .0301596 .114411 0.26 0.792 -.1940818 .2544011
          |
          Year |
          2003 | .3106028 2.539165 0.12 0.903 -4.666069 5.287274
          2004 | .0462483 2.92471 0.02 0.987 -5.686077 5.778574
          2005 | .4212648 3.414418 0.12 0.902 -6.270871 7.113401
          2006 | .614021 3.793916 0.16 0.871 -6.821917 8.049959
          2007 | .7052395 4.241089 0.17 0.868 -7.607142 9.017621
          2008 | .4955868 4.717857 0.11 0.916 -8.751243 9.742416
          2009 | .9206454 5.19201 0.18 0.859 -9.255507 11.0968
          2010 | .9869929 5.693338 0.17 0.862 -10.17174 12.14573
          2011 | .9502558 6.251671 0.15 0.879 -11.30279 13.20331
          2012 | 1.119757 6.786489 0.16 0.869 -12.18152 14.42103
          2013 | 1.304643 7.355838 0.18 0.859 -13.11254 15.72182
          |
          Age | .0943275 .6413924 0.15 0.883 -1.162779 1.351434
          Age_sq | -.0014554 .0019661 -0.74 0.459 -.005309 .0023981
          ---------------------------------------------------------------------------------
          
          .9 Quantile regression
          ---------------------------------------------------------------------------------
          | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          MV_shock_sc | .0025071 .0211082 0.12 0.905 -.0388642 .0438784
          MV_trend_sc | .0086394 .0268014 0.32 0.747 -.0438903 .0611691
          IND_MV_shock_sc | -.0005155 .0343643 -0.02 0.988 -.0678683 .0668373
          IND_MV_trend_sc | -.000205 .0296021 -0.01 0.994 -.058224 .057814
          GDP_growth | .0013726 .1153002 0.01 0.991 -.2246116 .2273568
          imf24 | .0000258 .0000424 0.61 0.543 -.0000573 .0001089
          imf33 | .0349671 .1579825 0.22 0.825 -.2746729 .344607
          |
          Year |
          2003 | .4271768 3.506163 0.12 0.903 -6.444776 7.299129
          2004 | .0617363 4.038536 0.02 0.988 -7.853649 7.977122
          2005 | .532264 4.714741 0.11 0.910 -8.708458 9.772986
          2006 | .7103026 5.238764 0.14 0.892 -9.557487 10.97809
          2007 | .7728639 5.856236 0.13 0.895 -10.70515 12.25088
          2008 | .5224137 6.514573 0.08 0.936 -12.24591 13.29074
          2009 | .9518544 7.1693 0.13 0.894 -13.09971 15.00342
          2010 | 1.022766 7.86155 0.13 0.896 -14.38559 16.43112
          2011 | .954458 8.632514 0.11 0.912 -15.96496 17.87388
          2012 | 1.123856 9.371009 0.12 0.905 -17.24298 19.4907
          2013 | 1.324015 10.15719 0.13 0.896 -18.5837 21.23173
          |
          Age | .0637183 .8856558 0.07 0.943 -1.672135 1.799572
          Age_sq | -.0011482 .0027149 -0.42 0.672 -.0064692 .0041729
          ---------------------------------------------------------------------------------
          
          
          . mat b=e(b_location)
          
          . mat g=e(b_scale)
          
          . mat c=e(b_50)
          
          . mat d=b,g,c
          
          . eststo: ereturn post d
          estimates post: matrix has missing values
          r(504);
          
          end of do-file
          
          r(504);
          
          . ssc install xtqreg, replace
          checking xtqreg consistency and verifying not already installed...
          all files already exist and are up to date.
          
          . mat list c
          
          symmetric c[1,1]
          c1
          r1 .
          
          
          . mat z=e(b)
          
          . mat list z
          
          z[1,21]
          2002b. 2003. 2004. 2005. 2006.
          MV_shock_sc MV_trend_sc IND_MV_sho~c IND_MV_tre~c GDP_growth imf24 imf33 Year Year Year Year Year
          y1 .00250712 .00863943 -.0005155 -.000205 .00137258 .00002579 .03496706 0 .42717677 .06173635 .53226403 .7103026
          
          2007. 2008. 2009. 2010. 2011. 2012. 2013.
          Year Year Year Year Year Year Year Age Age_sq
          y1 .77286391 .52241372 .95185438 1.0227665 .95445801 1.1238564 1.3240147 .06371834 -.00114818
          
          .

          Comment


          • Dear Michael Haylock,

            Please use ereturn post to see the saved results. I believe the estimates for the median are saved in e(b_5), not e(b_50).

            Best wishes,

            Joao

            Comment


            • Joao Santos Silva I would like to ask whether the Machado and Silva Quantile Regression mitigates the issue of endogeneity.
              Thanks.

              Mohamed


              Comment


              • Dear Mohamed Mahjoub Elheddad,

                There are 2 commands related to that paper: xtqreg allows for fixed effects and therefore deals with endogeneity only to the extent that the inclusion of the fixed effects can solve the endogeneity; ivqreg2 allows the estimation using instruments, but does not allow for fixed effects.

                Best wishes,

                Joao

                Comment


                • Originally posted by Joao Santos Silva View Post
                  Dear Mohamed Mahjoub Elheddad,

                  There are 2 commands related to that paper: xtqreg allows for fixed effects and therefore deals with endogeneity only to the extent that the inclusion of the fixed effects can solve the endogeneity; ivqreg2 allows the estimation using instruments, but does not allow for fixed effects.

                  Best wishes,

                  Joao
                  Thanks very much for this elaboration. Very appreciated.

                  Comment


                  • I am trying to test the equality of coefficients across quantiles--I know this can be done with bootstrapping, but I am unsure how to implement it. Would it be possible to request a very simple example?

                    Comment


                    • Dear Keith Dilts

                      Indeed you can use bootstrap to do it, but a simpler approach is to check whether the variable of interest has a significant coefficient in the scale function; that is a test for the null hypothesis that the coefficient on that variables is the same across all quantiles.

                      Best wishes,

                      Joao

                      Comment


                      • I need help on xtqreg please. I keep getting different results results with the same command.

                        Comment


                        • I need help on xtqreg please. I keep getting different results results with the same command.
                          Click image for larger version

Name:	stata.jpg
Views:	1
Size:	108.5 KB
ID:	1580643
                          Click image for larger version

Name:	stata2.jpg
Views:	1
Size:	110.0 KB
ID:	1580644

                          Comment


                          • THere is nothing wrong with your results.
                            You are requesting Bootstrap standard errors which depend on random draws. So every time you run it (unless you use "seeds") you will get different standard errors.

                            Comment


                            • Originally posted by FernandoRios View Post
                              THere is nothing wrong with your results.
                              You are requesting Bootstrap standard errors which depend on random draws. So every time you run it (unless you use "seeds") you will get different standard errors.
                              So i need to write 'seed'before my code? I mean this
                              seed
                              bootstrap, cluster(countrycode) idcluster(countryID) reps(100) : xtqreg gdppc lgdppc pop trade rir inf fdi dcpf i.yearavg5,i(countryID) ls q(0.9)

                              Comment


                              • Hello,

                                I am new to Stata so I am not familiar with many commands. I am using the xtqreg in my research and I was wondering if and how I could print the residuals.

                                Thank you in advance.

                                Kyriaki

                                Comment

                                Working...
                                X