Announcement

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

  • Multi-level Quantile Regression

    Hi all, I am wondering if there is a code for multi-level quantile regression. For instance, if I am analyzing student's test scores conditional on individual characteristics and school characteristics; is there a code in stata currently that can model it? For the sake of simplicity assume that the model to be estimated is y = x1 + x2, where y is test score, x1 is gender, and x2 is a school level variable for schools annual budget. I appreciate any and all help. Thanks. Daniel

  • #2
    By "multilevel modelling", I presume you want to introduce random intercepts (and possibly random slopes): the error term is a combination of school-effect and individual-level error. Just because you have a hierarchical structure doesn't mean that you have to fit this sort of model to account for the clustering into schools. You might also literally cluster on school_id, though I note that qreg allows for vce(robust) but not cluster-robust. However, a quick bit of Googling suggests that MLMs for quantile regression doesn't really exist. Off the top of my head, one complication that would have to be addressed is how to handle the random effects across equations for multiple quantiles.
    Whatever, there are possibly other questions about your study design to check, including e.g. sample sizes of number of schools and number of students within each school. If the former is small, you are unlikely to be able to reliably estimate any coefficient on your school-level predictor.

    Comment


    • #3
      Thank you Stephen! Do you happen to know how I can get robust standard errors with sqreg? Also, you are correct, I only need to take into account random intercepts. We are only trying to control for the clustered structure of the data. Also, the sample is fine; we fortunately have a large sample.

      Comment


      • #4
        I just looked at help qreg##sqreg_options and it appears that robust SE are available. (I still don't know how one would address the issue raised in the last sentence of my earlier first paragraph.)

        Comment


        • #5
          Dear All,
          I tried to impose -vce robust- to -qreg- and -sqreg-, but the latter does not seem to support this option:
          Code:
          . use "C:\Program Files (x86)\Stata13\ado\base\a\auto.dta", clear
          (1978 Automobile Data)
          
          . qreg price mpg rep78 , quantile(.25) vce(robust)
          Iteration  1:  WLS sum of weighted deviations =   48104.86
          
          Iteration  1: sum of abs. weighted deviations =  48012.417
          Iteration  2: sum of abs. weighted deviations =  35838.396
          Iteration  3: sum of abs. weighted deviations =  34683.125
          Iteration  4: sum of abs. weighted deviations =    34215.5
          Iteration  5: sum of abs. weighted deviations =   34114.25
          Iteration  6: sum of abs. weighted deviations =      33985
          
          .25 Quantile regression                              Number of obs =        69
            Raw sum of deviations  38720.5 (about 4187)
            Min sum of deviations    33985                     Pseudo R2     =    0.1223
          
          ------------------------------------------------------------------------------
                       |               Robust
                 price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                   mpg |       -113     19.815    -5.70   0.000    -152.5619   -73.43807
                 rep78 |      541.5   141.6934     3.82   0.000     258.6001    824.3999
                 _cons |     5045.5   424.8796    11.88   0.000       4197.2      5893.8
          ------------------------------------------------------------------------------
          
          . sqreg price mpg rep78 , quantile(.25 .5) vce(robust)
          option vce() not allowed
          r(198);
          
          
          .
          Kind regards,
          Carlo
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Dear All,

            You can do quantile regression with clustered standard errors (or just robust) using -qreg2-, which is available from SSC. If you need to estimate multiple quantiles simultaneously (which I do not think is the case), then the easiest thing is to do a "clustered" bootstrap.

            Joao

            Comment


            • #7
              Thank you all so much! This is extremely helpful.

              Comment


              • #8
                Joao, I actually do wish to estimate multiple quantiles simultaneously. Unfortunately, I have not been able to find how to perform the clustered bootstrap. Is this in sqreg2 or some other command? Also could I get the same results as a simultaneous estimation if I set the seed number at a fixed value and used sqreg2? Best, Daniel

                Comment


                • #9
                  Daniel,

                  Can you please explain why you need them to be estimated simultaneously rather than one-by-one? Do you want to impose or test cross-quantile restrictions?

                  Joao

                  Comment


                  • #10
                    Joao, I am interested in how some of the independent variables behave near the tails and testing for the significance that the effect varies across quantiles. My collaborator and I have not yet determined which quantiles to model, but we are interested in .05, .10, .20, .40, .60, .80, .90, and .95. From what I have seen a lot of researchers model quantiles across the distribution simultaneously. The purpose of the regression is for a research article in the social sciences. Best, Daniel

                    Comment


                    • #11
                      In that case you will need to write a small code to block-bootstrap the set of quantiles you want to estimate. You need to use the -bs- command with the option cluster() to bootstrap all the quantiles you need and get their joint covariance matrix (if you do not cluster the results are equivalent to what you get with sqreg). Please feel free to get in touch directly if this in not clear, OK?

                      Comment


                      • #12
                        Notwithstanding Joao's expert contributions, let me report that John Moran (Adelaide) emailed me privately to alert me to a paper (with associated R code) that implements MLM methods: Marco Geraci "Linear Quantile Mixed Models: The lqmm Package for Laplace Quantile Regression", Journal of Statistical Software, May 2014, Volume 57, Issue 13. Personally, I'd follow Joao, but others may be interested in this other approach.

                        Comment


                        • #13
                          Further to my post above, the easiest way to do it may be to use something like this:
                          Code:
                          bs _b , cluster(id) reps(500): sqreg y x, q(0.25 0.50 0,75) vce(iid,res)
                          The options vce(iid, res) is only there to speed up things; it won't affect the results. Of course, you should choose the number of replicas (500 in the example above) and the variable used to cluster (id in the example above).

                          Hope this works!

                          Joao

                          Comment


                          • #14
                            I tried to do block bootstrapping on quantile regression, for several quantiles at once, a while ago. I experienced a few problems, which were solved by Austin Nichols. Here's the thread:

                            http://www.stata.com/statalist/archi.../msg01052.html

                            Jorge Eduardo Pérez Pérez
                            www.jorgeperezperez.com

                            Comment


                            • #15
                              [QUOTE=Joao Santos Silva;n1305939]Further to my post above, the easiest way to do it may be to use something like this:
                              Code:
                              bs _b , cluster(id) reps(500): sqreg y x, q(0.25 0.50 0,75) vce(iid,res)
                              Hi Joao,

                              It looks like this command does not work if the data is xtset, unlike qreg2. The error message show 'repeated time values within panel'. If I remove xtset, the code works fine. Also I don't know why the vce(iid, res) option does not work.

                              I would like to thank you for all your posts on quantile regression. You explained QR in a very lucid way.

                              Comment

                              Working...
                              X