Code for Quantile Spacing Estimator of Schmidt and Zhu (2016)

R code

We have investigated the different options for running quantile regressions in MATLAB, STATA, SAS and R, and I have found, by a healthy margin, the user experience to be most pleasant in R. Roger Koenker's quantreg package is well-developed and mature. It also includes routines which perform well at scale (particularly with sparse X matrices), and the R interface is sufficiently flexible as to make it easy to modify code to impose zero restrictions and parallelize routines for inference.

Here is a sample script which estimates a simple model with 3 quantiles using our code. Our routines are a wrapper around Koenker's rq.fit.sfn, which implements the sparse Frisch-Newton algorithm from Koenker and Ng. I have used these routines successfully (with subsampling inference) at samples up to 15 million without encountering issues. For smaller datasets, performance could be easily optimized further by wrapping around alternative estimation routines from the quantreg package.

I also have code which interpolates between quantiles to evaluate densities, distribution functions, and quantile functions (which are useful if the objective is to simulate from a fitted model). I have easy-to-read R versions and substantially faster RCpp versions of these, which will be posted shortly. If you would like to use these codes, please email me and I will be happy to share what I currently have.

MATLAB and STATA routines

I have beta versions of MATLAB and STATA routines, but this code is still under construction. Please email me if you would like to experiment with them.