Announcement

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

  • Compare OLS and quantile regression coefficients

    Hello, I have 2 questions on testing whether the coefficients across OLS and quantile regressions are equal. Below are the models and codes I used.

    The model I use is simultaneous quantile regressions like this: Y = X1 + X2 + X3 + control (1)
    And the code I use is: sqreg Y X1 X2 X3 control, q(.25 .5 .75)

    I used test [q25=q50=q75]: X1 to test whether the coefficients are equal across quantiles.

    I was asked to cluster by permno, so I also test the model at p25 p50 p75 separately
    And the code I use is:
    qreg2 Y X1 X2 X3 control, q(.25) cluster(permno) (2)
    qreg2 Y X1 X2 X3 control, q(.5) cluster(permno) (2)
    qreg2 Y X1 X2 X3 control, q(.75) cluster(permno) (2)

    Now comes my 2 question:

    (1) I try to test whether the coefficients on X1 (also for X2 and X3) are equal between OLS and model 1 quantiles q25 q50 q75
    To do this, I tried to store OLS regression as ols, use suest, and then test [q25]X1=[q50]X1=[q75]X1=[ols]X1, but it gave me an error message.

    (2) I tried to test whether the coefficients on X1 are equal or not across the quantiles in regression 2
    again suest does not allow me to do the job.

    Could you please help me on this? Your inputs are greatly appreciated!

  • #2
    I do not think that what you want is possible with -suest-. -suest- is intended for use with subsambles on the same regression equation, or possibly different regression equations, but the same estimation method. In fact I think -suest- only handles OLS properly, that is it handles only -regress-.

    To do what you want to do, you can follow the procedure that -sqreg- does: bootstrap. You generate a bootstrap sample you estimate all the coefficients you are interested in, you store them, then you repeats this B number of times and you have a set of B observations where each observation is an estimate from each of your methods in a given bootstrap sample. Then you can do your testing from this.

    But this is not easy, requires a lot of work.

    Comment


    • #3
      Hi May,
      As Joro suggest, -suest- doesnt work well with qreg because it mostly uses regression "scores" (or residuals for OLS), to correct standard errors when estimating models jointly.
      I would suggest, however, that doing the bootstrap version is quite easy. Here a simple example you may want to use for your purposes:
      Code:
       webuse womenwk
      ** Create wrapper program for all models of interest. Make sure you add the eclass  at the end of the program
      
      capture program drop ols_vs_qreg
      program ols_vs_qreg, eclass
      ** estimate OLS
      reg wage age education married children
      matrix bols=e(b)
      ** estimate qreg 10 50 90 (or other of interest)
      qreg wage age education married children, q(10)
      matrix bq10=e(b)
      qreg wage age education married children, q(50)
      matrix bq50=e(b)
      qreg wage age education married children, q(90)
      matrix bq90=e(b)
      ** name equations across matrix
      matrix coleq bols = ols
      matrix coleq bq10= q10
      matrix coleq bq50= q50
      matrix coleq bq90= q90
      ** Put all b together
      matrix b = bols, bq10 , bq50 , bq90
      ** "post" them
      ereturn post b
      end
      ** Make sure you use the sample you actually need
      reg wage age education married children
      keep if e(sample)
      
      ** bootstrap
      
      bootstrap: ols_vs_qreg
       ** Output
      
      Bootstrap replications (50)
      ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
      ..................................................    50
      
      Bootstrap results                                        Number of obs = 1,343
                                                               Replications  =    50
      
      ------------------------------------------------------------------------------
                   |   Observed   Bootstrap                         Normal-based
                   | coefficient  std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
      ols          |
               age |   .1514818   .0197969     7.65   0.000     .1126805     .190283
         education |   .8750694   .0562646    15.55   0.000     .7647928    .9853459
           married |  -.5395024   .3333384    -1.62   0.106    -1.192834    .1138288
          children |  -.6862982   .1097916    -6.25   0.000    -.9014858   -.4711106
             _cons |   7.934369   .9855672     8.05   0.000     6.002693    9.866046
      -------------+----------------------------------------------------------------
      q10          |
               age |   .1362803   .0322593     4.22   0.000     .0730531    .1995074
         education |   .8601218    .090122     9.54   0.000     .6834859    1.036758
           married |  -1.231153    .543483    -2.27   0.023     -2.29636   -.1659458
          children |  -1.042808   .1492278    -6.99   0.000    -1.335289   -.7503267
             _cons |   3.123572    1.78768     1.75   0.081    -.3802155     6.62736
      -------------+----------------------------------------------------------------
      q50          |
               age |   .1653391    .021658     7.63   0.000     .1228902    .2077881
         education |   .8940777   .0757136    11.81   0.000     .7456818    1.042474
           married |  -.5971263   .4336936    -1.38   0.169     -1.44715    .2528975
          children |  -.6206084   .1337395    -4.64   0.000    -.8827329   -.3584839
             _cons |   6.906066    1.27135     5.43   0.000     4.414266    9.397867
      -------------+----------------------------------------------------------------
      q90          |
               age |   .1537102   .0265448     5.79   0.000     .1016832    .2057371
         education |   .9077313   .1045996     8.68   0.000     .7027199    1.112743
           married |   .3190477    .498328     0.64   0.522    -.6576572    1.295753
          children |  -.5730253   .1777933    -3.22   0.001    -.9214937   -.2245569
             _cons |   13.28619    1.57443     8.44   0.000     10.20036    16.37202
      ------------------------------------------------------------------------------
      After that, you can test coefficients across models as you would do with sqreg.
      HTH
      F

      Comment


      • #4
        Dear FernandoRios,

        Your solution is excellent, but I guess May Fang will want to do the bootstrap while accounting for the clustering, right?

        Best wishes,

        Joao

        Comment


        • #5
          Thanks Joao!
          That is true! (I just saw she was doing that with qreg2, not qreg.
          So, May, in that case you can add the cluster option in bootstrap. Although those results will be different from the ones produced by Joao's -qreg2-, because they will be based on the empirical, not asymptotic properties for quantile regressions.
          Something like this:
          Code:
          . bootstrap, cluster(county): ols_vs_qreg
          (running ols_vs_qreg on estimation sample)
          
          warning: ols_vs_qreg does not set e(sample), so no observations will be excluded from the resampling
                   because of missing values or other reasons. To exclude observations, press Break, save the
                   data, drop any observations that are to be excluded, and rerun bootstrap.
          
          Bootstrap replications (50)
          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
          ..................................................    50
          
          Bootstrap results                                        Number of obs = 1,343
                                                                   Replications  =    50
          
                                           (Replications based on 10 clusters in county)
          ------------------------------------------------------------------------------
                       |   Observed   Bootstrap                         Normal-based
                       | coefficient  std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
          ols          |
                   age |   .1514818   .0164449     9.21   0.000     .1192505    .1837131
             education |   .8750694   .0550743    15.89   0.000     .7671256    .9830131
               married |  -.5395024    .306771    -1.76   0.079    -1.140763    .0617577
              children |  -.6862982   .0887096    -7.74   0.000    -.8601658   -.5124306
                 _cons |   7.934369   1.028707     7.71   0.000     5.918141    9.950598
          -------------+----------------------------------------------------------------
          q10          |
                   age |   .1362803   .0232826     5.85   0.000     .0906473    .1819133
             education |   .8601218   .0656075    13.11   0.000     .7315335    .9887101
               married |  -1.231153   .5198543    -2.37   0.018    -2.250049   -.2122572
              children |  -1.042808   .1780629    -5.86   0.000    -1.391805   -.6938109
                 _cons |   3.123572   1.287632     2.43   0.015     .5998602    5.647285
          -------------+----------------------------------------------------------------
          q50          |
                   age |   .1653391   .0244855     6.75   0.000     .1173484    .2133299
             education |   .8940777   .0873886    10.23   0.000     .7227991    1.065356
               married |  -.5971263   .3937529    -1.52   0.129    -1.368868    .1746151
              children |  -.6206084   .1416982    -4.38   0.000    -.8983318    -.342885
                 _cons |   6.906066   1.607285     4.30   0.000     3.755845    10.05629
          -------------+----------------------------------------------------------------
          q90          |
                   age |   .1537102   .0231695     6.63   0.000     .1082987    .1991216
             education |   .9077313   .0903143    10.05   0.000     .7307185    1.084744
               married |   .3190477   .5291344     0.60   0.547    -.7180367    1.356132
              children |  -.5730253   .1314047    -4.36   0.000    -.8305738   -.3154768
                 _cons |   13.28619   1.298303    10.23   0.000     10.74156    15.83082
          ------------------------------------------------------------------------------
          
          ** compared to 
          
          
          . qreg2 wage age education married children, q(.90) cluster(county)
          
          .9 Quantile regression
          R-squared = .27387666
          Number of obs = 1343
          Objective function = .94910521
          
          Standard errors adjusted for 10 clusters in county
          ------------------------------------------------------------------------------
                  wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                   age |   .1537102   .0247034     6.22   0.000     .1052923     .202128
             education |   .9077313   .1018411     8.91   0.000     .7081264    1.107336
               married |   .3190477   .6381099     0.50   0.617    -.9316248     1.56972
              children |  -.5730253   .1229804    -4.66   0.000    -.8140625   -.3319881
                 _cons |   13.28619   1.264325    10.51   0.000     10.80816    15.76422
          ------------------------------------------------------------------------------
          HTH

          Comment


          • #6
            Originally posted by Joro Kolev View Post
            I do not think that what you want is possible with -suest-. -suest- is intended for use with subsambles on the same regression equation, or possibly different regression equations, but the same estimation method. In fact I think -suest- only handles OLS properly, that is it handles only -regress-.

            To do what you want to do, you can follow the procedure that -sqreg- does: bootstrap. You generate a bootstrap sample you estimate all the coefficients you are interested in, you store them, then you repeats this B number of times and you have a set of B observations where each observation is an estimate from each of your methods in a given bootstrap sample. Then you can do your testing from this.

            But this is not easy, requires a lot of work.
            Joro,

            Thank you for your comment. Indeed, almost every time I have successfully used suest, it was for "regress".

            Comment


            • #7
              Originally posted by FernandoRios View Post
              Thanks Joao!
              That is true! (I just saw she was doing that with qreg2, not qreg.
              So, May, in that case you can add the cluster option in bootstrap. Although those results will be different from the ones produced by Joao's -qreg2-, because they will be based on the empirical, not asymptotic properties for quantile regressions.
              Something like this:
              Code:
              . bootstrap, cluster(county): ols_vs_qreg
              (running ols_vs_qreg on estimation sample)
              
              warning: ols_vs_qreg does not set e(sample), so no observations will be excluded from the resampling
              because of missing values or other reasons. To exclude observations, press Break, save the
              data, drop any observations that are to be excluded, and rerun bootstrap.
              
              Bootstrap replications (50)
              ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
              .................................................. 50
              
              Bootstrap results Number of obs = 1,343
              Replications = 50
              
              (Replications based on 10 clusters in county)
              ------------------------------------------------------------------------------
              | Observed Bootstrap Normal-based
              | coefficient std. err. z P>|z| [95% conf. interval]
              -------------+----------------------------------------------------------------
              ols |
              age | .1514818 .0164449 9.21 0.000 .1192505 .1837131
              education | .8750694 .0550743 15.89 0.000 .7671256 .9830131
              married | -.5395024 .306771 -1.76 0.079 -1.140763 .0617577
              children | -.6862982 .0887096 -7.74 0.000 -.8601658 -.5124306
              _cons | 7.934369 1.028707 7.71 0.000 5.918141 9.950598
              -------------+----------------------------------------------------------------
              q10 |
              age | .1362803 .0232826 5.85 0.000 .0906473 .1819133
              education | .8601218 .0656075 13.11 0.000 .7315335 .9887101
              married | -1.231153 .5198543 -2.37 0.018 -2.250049 -.2122572
              children | -1.042808 .1780629 -5.86 0.000 -1.391805 -.6938109
              _cons | 3.123572 1.287632 2.43 0.015 .5998602 5.647285
              -------------+----------------------------------------------------------------
              q50 |
              age | .1653391 .0244855 6.75 0.000 .1173484 .2133299
              education | .8940777 .0873886 10.23 0.000 .7227991 1.065356
              married | -.5971263 .3937529 -1.52 0.129 -1.368868 .1746151
              children | -.6206084 .1416982 -4.38 0.000 -.8983318 -.342885
              _cons | 6.906066 1.607285 4.30 0.000 3.755845 10.05629
              -------------+----------------------------------------------------------------
              q90 |
              age | .1537102 .0231695 6.63 0.000 .1082987 .1991216
              education | .9077313 .0903143 10.05 0.000 .7307185 1.084744
              married | .3190477 .5291344 0.60 0.547 -.7180367 1.356132
              children | -.5730253 .1314047 -4.36 0.000 -.8305738 -.3154768
              _cons | 13.28619 1.298303 10.23 0.000 10.74156 15.83082
              ------------------------------------------------------------------------------
              
              ** compared to
              
              
              . qreg2 wage age education married children, q(.90) cluster(county)
              
              .9 Quantile regression
              R-squared = .27387666
              Number of obs = 1343
              Objective function = .94910521
              
              Standard errors adjusted for 10 clusters in county
              ------------------------------------------------------------------------------
              wage | Coefficient Std. err. z P>|z| [95% conf. interval]
              -------------+----------------------------------------------------------------
              age | .1537102 .0247034 6.22 0.000 .1052923 .202128
              education | .9077313 .1018411 8.91 0.000 .7081264 1.107336
              married | .3190477 .6381099 0.50 0.617 -.9316248 1.56972
              children | -.5730253 .1229804 -4.66 0.000 -.8140625 -.3319881
              _cons | 13.28619 1.264325 10.51 0.000 10.80816 15.76422
              ------------------------------------------------------------------------------
              HTH

              Fernando,

              Really appreciate your inputs! I am going to test it and get back here.

              Comment

              Working...
              X