Announcement

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

  • Quantile regression

    Dear Joao Santos Silva ,

    I have already asked about this, but I still having problems with the regression. So, I would appreciate your help. I createad this quantile regression following your advice, but I have been told that it is not correct.

    Code:
    xtset cnt_enc
    
    xtqreg ln_manEMP lnPop lnPop_sq lngdppc lngdppc_sq fdi ln_fdi remitt ln_remitt foreignaid ln_foreignaid i.year, ls q(0.25, 0.5, 0.75)
    Can you help me? You also advice me to add the bootsrap command, but I do not know how to do it.

    Thanks in advance,
    Best
    Lucia







  • #2
    Dear Lucia Gracia,

    Why is it not correct? On the bootstrap, please check the example here (you can ignore the bit about c>=10).

    Best wishes,

    Joao

    Comment


    • #3
      Thank yoiu Joao Santos Silva,


      My professor told me the tables I obtained were wrong. I have a panel data of 31 countries and 29 years, 899 observations in total. I want to add fixed effects for countries and years.

      I added the bootstrap like in your example:


      Code:
      xtset cnt_enc year
      
      bs, cl(id) r(50) id(cnt_enc): xtqreg manEMP lnPop lnPop_sq lngdppc lngdppc_sq fdi ln_fdi remitt ln_remitt foreignaid ln_foreignaid i.year i.cnt_enc, q(0.25, 0.5, 0.75)

      but, I got this:

      WARNING: 1.89099% of the fitted values of the scale function are not positive

      Bootstrap replications (50): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx done
      x: Error occurred when bootstrap executed xtqreg.
      insufficient observations to compute bootstrap standard errors
      no results will be saved
      r(2000);

      I do not know what I can do, can you help me?

      Best,
      Lucía

      Comment


      • #4
        Dear Lucia Gracia,

        Do not worry about the warning. You are not using the command as in the example.
        1) xtset only by cnt_enc
        2) Keep in mind that xtqreg automatically included the cnt_enc fixed effects, so to not include these in the model.
        3) Make sure you the bootstrap as in the example.

        Best wishes,

        Joao

        Comment


        • #5
          Dear Joao Santos Silva ,

          Thanks for your help, it worked. I just have one last question if you do not mind.

          My results with a previous linear regression were mostly significant, but with this quantile regression I obtain insignificant results. Why could be so?

          Best regards,

          Lucía

          Comment


          • #6
            Your earlier regression probably did not include fixed effects?
            Last edited by Joao Santos Silva; 29 May 2024, 00:36.

            Comment


            • #7
              I also included year and country fixed effects for the previous regression.

              Comment


              • #8
                Use the option ls in xtqreg and see if the results match. If the estimates are different, the models are different, If it is only the SE that are different, maybe you did not use robust standard errors? If this does not answer your question, please post the two sets of results (using the right delimiters).

                Comment


                • #9
                  Thanks!

                  I did this at the end. I also wanted to use the quantile regression for subdivisions of my sample, but I think xtqreg is not useful for less than 10 countries sample, right?

                  Code:
                  . eststo s1: bs, cluster(cnt_enc) rep(500): xtqreg manEMP lnPop lnPop_sq lngdppc 
                  > lngdppc_sq fdi1 remitt foreignaid1 i.year, ls q(0.25)
                  (running xtqreg on estimation sample)
                                                                             Location parameters
                                                                                Scale parameters
                  WARNING: 2.3359288% of the fitted values of the scale function are not positive
                  
                  Bootstrap replications (500): .........10.........20.........30.........40.......
                  > ..50.........60.........70.........80.........90.........100.........110.......
                  > ..120.........130.........140.........150.........160.........170.........180..
                  > .......190.........200.........210.........220.........230.........240.........
                  > 250.........260.........270.........280.........290.........300.........310....
                  > .....320.........330.........340.........350.........360.........370.........38
                  > 0.........390.........400.........410.........420.........430.........440......
                  > ...450.........460.........470.........480.........490.........500 done
                  
                  Bootstrap results                                          Number of obs = 899
                                                                             Replications  = 500
                  
                                                  (Replications based on 31 clusters in cnt_enc)
                  ------------------------------------------------------------------------------
                               |   Observed   Bootstrap                         Normal-based
                        manEMP | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                         lnPop |  -.0927677   .1596205    -0.58   0.561     -.405618    .2200827
                      lnPop_sq |   .0031597   .0046362     0.68   0.496     -.005927    .0122464
                       lngdppc |   .3247265    .089008     3.65   0.000      .150274     .499179
                    lngdppc_sq |   -.020143   .0056077    -3.59   0.000    -.0311339   -.0091521
                          fdi1 |  -.1140955   .0666219    -1.71   0.087    -.2446719    .0164809
                        remitt |  -.0251568   .0924306    -0.27   0.785    -.2063175    .1560038
                   foreignaid1 |   -.182364   .1038098    -1.76   0.079    -.3858274    .0210994
                               |
                          year |
                         1991  |   .0024906    .002174     1.15   0.252    -.0017704    .0067516
                         1992  |   .0059991   .0039114     1.53   0.125    -.0016671    .0136652
                         1993  |   .0075807   .0052863     1.43   0.152    -.0027802    .0179416
                         1994  |   .0116205   .0069138     1.68   0.093    -.0019303    .0251713
                         1995  |   .0111865   .0081258     1.38   0.169    -.0047397    .0271128
                         1996  |   .0123331   .0090359     1.36   0.172     -.005377    .0300432
                         1997  |   .0124426   .0097484     1.28   0.202     -.006664    .0315492
                         1998  |    .009756   .0104444     0.93   0.350    -.0107147    .0302266
                         1999  |   .0087197   .0113886     0.77   0.444    -.0136016     .031041
                         2000  |   .0093158   .0125195     0.74   0.457     -.015222    .0338537
                         2001  |   .0105706   .0134823     0.78   0.433    -.0158541    .0369954
                         2002  |   .0114262   .0146315     0.78   0.435     -.017251    .0401034
                         2003  |    .010635   .0153861     0.69   0.489    -.0195212    .0407913
                         2004  |   .0139318   .0161469     0.86   0.388    -.0177155    .0455791
                         2005  |   .0148417   .0172553     0.86   0.390    -.0189782    .0486615
                         2006  |   .0170212    .018455     0.92   0.356    -.0191499    .0531923
                         2007  |   .0157797   .0192936     0.82   0.413     -.022035    .0535945
                         2008  |   .0142864   .0201606     0.71   0.479    -.0252277    .0538004
                         2009  |   .0092623   .0209186     0.44   0.658    -.0317375     .050262
                         2010  |   .0111292   .0219996     0.51   0.613    -.0319891    .0542475
                         2011  |   .0137383    .023124     0.59   0.552     -.031584    .0590605
                         2012  |    .013993   .0243992     0.57   0.566    -.0338285    .0618144
                         2013  |    .015331   .0255658     0.60   0.549     -.034777     .065439
                         2014  |   .0143813    .026027     0.55   0.581    -.0366307    .0653932
                         2015  |   .0186217   .0266522     0.70   0.485    -.0336156    .0708591
                         2016  |   .0174581   .0270788     0.64   0.519    -.0356153    .0705315
                         2017  |   .0192564   .0278411     0.69   0.489     -.035311    .0738239
                         2018  |   .0195152    .028845     0.68   0.499    -.0370199    .0760504
                  ------------------------------------------------------------------------------
                  
                  . 
                  . eststo s11: bs, cluster(cnt_enc) rep(500): xtqreg manEMP lnPop lnPop_sq lngdppc
                  >  lngdppc_sq fdi1 remitt foreignaid1 i.year, ls q(0.5)
                  (running xtqreg on estimation sample)
                                                                             Location parameters
                                                                                Scale parameters
                  WARNING: 2.3359288% of the fitted values of the scale function are not positive
                  
                  Bootstrap replications (500): .........10.........20.........30.........40.......
                  > ..50.........60.........70.........80.........90.........100.........110.......
                  > ..120.........130.........140.........150.........160.........170.........180..
                  > .......190.........200.........210.........220.........230.........240.........
                  > 250.........260.........270.........280.........290.........300.........310....
                  > .....320.........330.........340.........350.........360.........370.........38
                  > 0.........390.........400.........410.........420.........430.........440......
                  > ...450.........460.........470.........480.........490.........500 done
                  
                  Bootstrap results                                          Number of obs = 899
                                                                             Replications  = 500
                  
                                                  (Replications based on 31 clusters in cnt_enc)
                  ------------------------------------------------------------------------------
                               |   Observed   Bootstrap                         Normal-based
                        manEMP | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                         lnPop |  -.0455358   .1646567    -0.28   0.782     -.368257    .2771853
                      lnPop_sq |   .0016424    .004917     0.33   0.738    -.0079946    .0112795
                       lngdppc |   .3542114   .0873258     4.06   0.000      .183056    .5253668
                    lngdppc_sq |  -.0223611   .0055757    -4.01   0.000    -.0332893   -.0114328
                          fdi1 |  -.0858002   .0595399    -1.44   0.150    -.2024962    .0308959
                        remitt |  -.0303432    .086144    -0.35   0.725    -.1991824     .138496
                   foreignaid1 |  -.1865193   .0874872    -2.13   0.033     -.357991   -.0150476
                               |
                          year |
                         1991  |   .0006587   .0017966     0.37   0.714    -.0028626      .00418
                         1992  |   .0013588   .0030184     0.45   0.653    -.0045572    .0072748
                         1993  |   .0006869   .0042751     0.16   0.872    -.0076922     .009066
                         1994  |   .0031872   .0058454     0.55   0.586    -.0082696    .0146441
                         1995  |   .0016991   .0072799     0.23   0.815    -.0125692    .0159675
                         1996  |   .0025381   .0085415     0.30   0.766    -.0142028    .0192791
                         1997  |   .0030955   .0093016     0.33   0.739    -.0151352    .0213262
                         1998  |   .0008436   .0099971     0.08   0.933    -.0187504    .0204375
                         1999  |  -.0000759   .0109475    -0.01   0.994    -.0215327    .0213809
                         2000  |   .0003432   .0120093     0.03   0.977    -.0231946    .0238809
                         2001  |   .0005197   .0128075     0.04   0.968    -.0245824    .0256219
                         2002  |   .0010178   .0138981     0.07   0.942    -.0262219    .0282575
                         2003  |   .0008507   .0148075     0.06   0.954    -.0281714    .0298728
                         2004  |   .0036356   .0158792     0.23   0.819     -.027487    .0347582
                         2005  |   .0053226   .0170383     0.31   0.755    -.0280718     .038717
                         2006  |   .0081196   .0182353     0.45   0.656    -.0276209    .0438601
                         2007  |   .0082401   .0190837     0.43   0.666    -.0291633    .0456435
                         2008  |   .0079327   .0199619     0.40   0.691    -.0311919    .0470573
                         2009  |   .0034394   .0208204     0.17   0.869    -.0373679    .0442467
                         2010  |   .0058616   .0219328     0.27   0.789    -.0371259    .0488491
                         2011  |   .0089516   .0230901     0.39   0.698    -.0363041    .0542072
                         2012  |   .0111877   .0244464     0.46   0.647    -.0367264    .0591019
                         2013  |   .0143546   .0255866     0.56   0.575    -.0357942    .0645034
                         2014  |   .0144421   .0265047     0.54   0.586    -.0375062    .0663903
                         2015  |   .0173116    .027401     0.63   0.528    -.0363934    .0710166
                         2016  |   .0163881    .028212     0.58   0.561    -.0389065    .0716827
                         2017  |   .0184948   .0292225     0.63   0.527    -.0387803    .0757699
                         2018  |   .0197102   .0301877     0.65   0.514    -.0394566     .078877
                  ------------------------------------------------------------------------------
                  
                  . 
                  . eststo s111: bs, cluster(cnt_enc) rep(500): xtqreg manEMP lnPop lnPop_sq lngdpp
                  > c lngdppc_sq fdi1 remitt foreignaid1 i.year, ls q(0.75)
                  (running xtqreg on estimation sample)
                                                                             Location parameters
                                                                                Scale parameters
                  WARNING: 2.3359288% of the fitted values of the scale function are not positive
                  
                  Bootstrap replications (500): .........10.........20.........30.........40.......
                  > ..50.........60.........70.........80.........90.........100.........110.......
                  > ..120.........130.........140.........150.........160.........170.........180..
                  > .......190.........200.........210.........220.........230.........240.........
                  > 250.........260.........270.........280.........290.........300.........310....
                  > .....320.........330.........340.........350.........360.........370.........38
                  > 0.........390.........400.........410.........420.........430.........440......
                  > ...450.........460.........470.........480.........490.........500 done
                  
                  Bootstrap results                                          Number of obs = 899
                                                                             Replications  = 500
                  
                                                  (Replications based on 31 clusters in cnt_enc)
                  ------------------------------------------------------------------------------
                               |   Observed   Bootstrap                         Normal-based
                        manEMP | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                         lnPop |   .0112382   .1800316     0.06   0.950    -.3416172    .3640936
                      lnPop_sq |  -.0001813   .0053281    -0.03   0.973    -.0106242    .0102615
                       lngdppc |   .3896532   .0881091     4.42   0.000     .2169624    .5623439
                    lngdppc_sq |  -.0250272   .0056318    -4.44   0.000    -.0360653   -.0139891
                          fdi1 |  -.0517883   .0587578    -0.88   0.378    -.1669515    .0633749
                        remitt |  -.0365773   .0681632    -0.54   0.592    -.1701747    .0970201
                   foreignaid1 |   -.191514   .0829704    -2.31   0.021     -.354133   -.0288951
                               |
                          year |
                         1991  |  -.0015433   .0020817    -0.74   0.458    -.0056233    .0025367
                         1992  |  -.0042189   .0028015    -1.51   0.132    -.0097097    .0012718
                         1993  |  -.0075997   .0038342    -1.98   0.047    -.0151146   -.0000847
                         1994  |  -.0069498   .0053089    -1.31   0.191     -.017355    .0034554
                         1995  |   -.009705   .0066223    -1.47   0.143    -.0226845    .0032746
                         1996  |  -.0092357   .0080229    -1.15   0.250    -.0249603    .0064889
                         1997  |    -.00814   .0090607    -0.90   0.369    -.0258986    .0096185
                         1998  |  -.0098694    .009663    -1.02   0.307    -.0288085    .0090697
                         1999  |  -.0106484   .0108337    -0.98   0.326    -.0318821    .0105852
                         2000  |  -.0104423   .0117156    -0.89   0.373    -.0334044    .0125199
                         2001  |  -.0115618   .0125127    -0.92   0.355    -.0360862    .0129627
                         2002  |  -.0114934   .0133976    -0.86   0.391    -.0377522    .0147654
                         2003  |  -.0109104   .0147949    -0.74   0.461     -.039908    .0180871
                         2004  |  -.0087407   .0161488    -0.54   0.588    -.0403918    .0229103
                         2005  |  -.0061197   .0173752    -0.35   0.725    -.0401745    .0279351
                         2006  |  -.0025804    .018688    -0.14   0.890    -.0392081    .0340474
                         2007  |  -.0008227   .0196497    -0.04   0.967    -.0393354      .03769
                         2008  |   .0002953   .0206698     0.01   0.989    -.0402167    .0408073
                         2009  |  -.0035598   .0218082    -0.16   0.870    -.0463031    .0391835
                         2010  |  -.0004702   .0230172    -0.02   0.984    -.0455832    .0446427
                         2011  |   .0031977    .024459     0.13   0.896     -.044741    .0511365
                         2012  |   .0078157   .0261992     0.30   0.765    -.0435338    .0591652
                         2013  |   .0131809   .0276254     0.48   0.633    -.0409638    .0673255
                         2014  |   .0145151   .0289914     0.50   0.617     -.042307    .0713373
                         2015  |   .0157368    .030151     0.52   0.602    -.0433581    .0748317
                         2016  |   .0151019   .0315415     0.48   0.632    -.0467183    .0769221
                         2017  |   .0175793   .0328248     0.54   0.592    -.0467561    .0819148
                         2018  |   .0199446    .033791     0.59   0.555    -.0462845    .0861736
                  ------------------------------------------------------------------------------
                  
                  . 
                  . 
                  . 
                  . esttab s1 s11 s111, se starlevels(* 0.10 ** 0.05 *** 0.01) stat(N r2, fmt(0 3))
                  > , using qregDRIV.rtf, keep(lnPop lnPop_sq lngdppc lngdppc_sq fdi1 remitt foreig
                  > naid1) b(3) se(3) nogaps replace
                  (output written to qregDRIV.rtf)
                  Best,
                  Lucía

                  Comment

                  Working...
                  X