## MATLAB code for quantile regression

Here are a couple MATLAB functions that perform nonlinear quantile regression.
1. ipqr.m, which uses an interior point method of Koenker and Park (1996, J. Econometrics). This function requires a second supporting function, ipqr_objfunc.m.
2. mmqr.m, which uses a Majorize-Minimize method of Hunter and Lange (2000, J. Comp. Graph. Statistics).
Each of these functions requires two additional supporting functions that calculate, for a given value of the parameter vector beta, the vector of regression function values and the matrix of partial derivatives of the regression function. See the comments contained in the code for further details. Below is the code for the common (very simple!) case of linear quantile regression and a nonlinear example in Section 5 of the Hunter and Lange paper, followed by code for each of the test problems in Koenker and Park's 1996 paper. Note that each of the test problems requires a response vector and (sometimes) a predictor matrix as well; these can be found by reading the 1996 paper.
In order to write new objective functions, just name one of them, say, FUNC.m, which means that the other should be named dFUNC.m. The requirements of these functions are as follows:
• The function FUNC.m should take two arguments, an nxm matrix of covariates and a px1 vector of parameters, and return an nx1 vector of values, where the ith entry is the function evaluated for the ith row of the covariate matrix. Note that it is not necessary that m=p, though that is certainly true in the linear case, where the vector returned is just the matrix product of the covariate matrix and the parameter vector.
• The function dFUNC.m should take the same two arguments as FUNC.m, but it should return an nxp matrix, where the (i,j) entry of the matrix is the partial derivative of the function with respect to the jth parameter, evaluated at the ith row of the covariate matrix and the given parameter vector. Thus, for example, in the linear case, dFUNC.m simply returns the covariate matrix itself.
Here is a sample script for running in batch mode, which requires the Matlab routine tester.m. (Note: I had to make some small changes to these files when I posted them, and I haven't tested them with those changes. Thus, I don't guarantee them to be bug-free.)