Qreg
A GAUSS Library for Computing Quantile Regression
Key Definitions and Implementation

Damien Jacomy, Jérôme Messines and Thierry RoncalliGroupe de Recherche Opérationnelle, Crédit Lyonnais, France
August 2000
(English version April 2001)

Contents
1 Introduction

22 Main topic

2

3 Introducing M -estimators
3.1 Background on M -estimators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Quantile regression and M -estimators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22
3

4 Estimation of the parameters by linear programming
4.1 Reformulation of the problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Interior-point method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Application to quantile regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4
4
4
5
5

5 Local linear (or quadratic) regression
5.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Beyond the Normal distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
6
6

References

6

A The GAUSS Qreg library
A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.2 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.2.1 The file readme.Qreg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.2.2 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.3 What is Qreg? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.4 Using Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 Command reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8
8
8
8
8
8
9
9
9
14

1

Introduction

Quantile regression turns out to be a very suitable method when usual linear regression comes up against
robustness problems. Moreover, the entire conditional distribution of a response Y given values x of apredictor X may prove as relevant as the only conditional mean function. That is why we try in this article
to summarize key definitions and practical use of quantile regression models.
First, we detail basic principles of the method and its implementation thanks to linear programming.
We try to solve the following problem: given a response Y to a predictor X, we use a linear model of theconditional τ -quantile of Y given X = x. Then, using the above-mentioned results, we explain how we canimplement the methods proposed by Yu and Jones [8] as regards local linear (or quadratic) regression andshow the advantages of those techniques.

2

Main topic

Given a random variable Y and its distribution function F, we denote by
Q (τ ) = inf {y | F (y) ≥ τ }(1)the τ th quantile of Y . The sample analogue q of Q (τ ) is called the τ th sample quantile and may be formulated
as the solution of the following optimization problem, given a random sample (yn )n=1,...,N :X
X(1 − τ ) |yn − q|min(2)
τ |yn − q| +q∈R{n|yn ≥q}{n|yn <q}

For any 0 < τ < 1, we denote ρτ (u) = u × τ − 1[u<0] , so that the problem may be formulated as follows
min
q∈R

N
X

n=1

ρτ (yn − q)(3)which yields a natural generalization to the regression context. The linear conditional quantile function canbe estimated by solving, for X ∈ RK and β ∈ RK :
min

β∈RK

3

Introducing M -estimators

3.1

Background on M -estimators

N
X

n=0



ρτ yn − x>nβ(4)

We use here the results presented in Gouriéroux and Monfort [1]. Considering a parametric or semiparametric model with parameter θ ∈ Θ and observations (Xn , Yn )n=1,...,N , we have:
Definition 1 A M -estimator of a function g (θ) is the solution of an optimization problem in the formming∈g(Θ)NX

Ψ (Yn , Xn ; g)

(5)

n=1

The study of M -estimators is very similar to that of maximum likelihood estimators. The original idea is toreplace the above-mentioned problem by the associated limit problem:
min EX E0 Ψ (Y, X; g)g∈g(Θ)(6)

where E0 is the expectation under the “true” conditional distribution of Y given X = x and EX is the
expectation under the “true” marginal distribution of X.
The following theorem ensures convergence of M -estimators towards the “true” limit:
2

Theorem 1 If
1. the pairs (Xn , Yn ) are i.i.d.,
2. G = g (Θ) is a compact (or open) set,
3. Ψ is a continuous function of g, and its expectation under to the “true” distribution of (X, Y ) exists
for any g,
PN
4. N1 n=1 Ψ (Yn , Xn ; g) is almost surely uniformly convergent on G to EX E0 Ψ (Yn , Xn ; g),0
5. the only solution of the problem (6) is g∞= g∞ (θ0 ), where θ0 is the parameter of the “true” distribution,

then, there exists a M -estimator that converges to g (θ0 ) if and only if ∀ θ ∈ Θ, g∞ (θ) = g (θ).
Thus when regularity conditions are established, we only have to prove that the solution of (6) is the expected
one, whatever the value of the parameter.

3.2

Quantile regression and M -estimators

Let us fix τ ∈ ]0, 1[, and study how the program (4) provides us with an estimation of Qτ (Y | X = x).
Suppose that Yn = q (Xn , β) + un , where q is a continuous function of β and the random variables un are
i.i.d. such that Pr {un ≤ 0} = τ . We then have Qτ (Y | X = x; β) = q (X, β). The point is to verify the
hypothesis of Theorem 1 when estimating β with Ψ (Yn , Xn ; β) = ρτ (Yn − q (Xn , β)). Suppose now that• the pairs (Xn , Yn ) are independent and identically distributed,• and ∀ a ∈ R, E [|Y − a|] exists.
Following Theorem 1, the sequence of M -estimators β̂ N converges to β 0 if and only if β 0 is the only solutionofmin Ψ∞ (Y, X; β) = EX E0 ρτ (Y − q (X, β))
(7)
β∈RK

Proposition 2 If the τ -quantile of Y | X = x is unique and defined by q (X, β 0 ), and if β is entirely
determined by the conditional τ -quantile 1 , then β 0 is the only solution of minβ∈RK Ψ∞ (Y, X; β).
Proof. Let f and F be the density and distribution functions of the residuals u. Let a be any real
number. We have:Zτ (u − a) 1[u−a>0] + (τ − 1) (u − a) 1[u−a≤0] f (u) duEρτ (u − a) =
Z Z
Z Z
=
τ 1[u>t>a] dt · f (u) du +(1 − τ ) 1[u≤t≤a] dt · f (u) duZInterchanging symbols , we getZ=τ (1 − F (t)) 1[t>a] + (1 − τ ) F (t) 1[t≤a] dt
Z


=
(8)
(τ − F (t)) 1[t>a] + (1 − τ ) F (t) dt
The minimum of this expression is achieved for any a verifying Pr {u ≤ a} = τ . The problem (6) may bereformulated with u:min ρτ (u + q (X, β 0 ) − q (X, β))β∈RKThe solution is then defined by q (X, β 0 ) − q (X, β) = 0, i.e. β 0 .
1 i.e. [∀ x, h (x, β) = h (x, β0 )] ⇒ β = β 0 .

34Estimation of the parameters by linear programming

We suppose here that we have for the conditional quantile function a linear statistical model in the formq (X, β) = X > β. In this case, the optimization may be formulated as an usual linear programming problem.

4.1

Reformulation of the problem

Write Y with only positive terms:
YnXn> β + un

=

K
X

=

xn,k β k + un

k=1
K
X

=

k=1



−
+
−
xn,k β +n − β n + un − un(9)The optimization program (4) can be written asz= arg min c> zAz = y
u.c.
z≥0

(10)

where
>

X

= (X1 , . . . , XN )A

= (X, −X, IN , −IN )

y
z

c

>

= (Y1 , . . . , YN ) + β
 β− 
2K+2N
= 
 u+  ∈ R
u−


0


0

= 


τ1
(1 − τ ) 1(11)Thus, solving the former optimization problem consists in minimizing a linear function subject to linear
constraints.
When considering the simplex method to solve the program, one is confronted with computational issues:
how to save and manipulate the constraints matrix, when the number of observations becomes important —dim A ' N × 2N . Moreover, one has to deal with the well-known slowness of the procedure. That is why
the interior-point method, rather fast when applied to large data sets, is more suitable.

4.2

Interior-point method

Theoretical developments of this method are extensively presented in Bonnans, Gilbert, Lemaréchal
and Sagastizábal [2]. We refer to Portnoy and Koenker [5] for its application to quantile regression.
The original idea of interior-point methods is to replace a linear program with bounded variables, suchas
min c> xxu.c. x ≥ 0

(12)

X

(13)

with a sequence of µ-programs
min c> x − µ
x

4

m

ln xm

The logarithmic barrier functions accounts for positivity constraints on x coordinates, becoming infinite
as x approaches the boundary of the feasible set. Starting from a feasible point, we perform a standard
Newton optimization procedure to find the “right” direction and we choose the step that minimizes thebarrier function. For more details, please refer to Portnoy and Koenker [5].

4.3

Application to quantile regression

Just know that for reasons of symmetry as well as computability, we introduce the dual program:a =arg max y > a >X a = (1 − τ ) X > 1u.c.
a ∈ [0, 1]N(14)

Please refer to Portnoy and Koenker [5] for further details.

4.4

Implementation

The procedures of the Qreg library are adapted from a program by Roger Koenker. This program may befound athttp://www.econ.uiuc.edu/~roger/research/rqn

5Local linear (or quadratic) regression

5.1

Principle

We want to estimate at any point the conditional τ th -quantile of Y given X = x. Our key article is Yu
and Jones [8]. The most natural idea for such an estimation is to choose observations of Y such as theassociated X is near x and to calculate the τ th -quantile on this sample. Denoting h the bandwidth, it implies
calculating the quantile of observations of Y with weight 1 if distance from X to x is at most h and 0 else.
In the same approach, we can consider performing kernel weighted local linear fitting, allowing all observations to be taken into account. Denoting K the kernel function (Gaussian, Epanechnikov, etc.), we
calculate the quantile of Y thanks to the program (2) in a weighted version. Our quantile q is then obtainedby solving the following problemNXminwn ρτ (yn − q)
(15)
q∈R

n=1

with




x − xnwn = K(16)hh is now a scale parameter controlling the amount of smoothing applied to the data. In practice, thisapproach gives questionable results when there is a strong functional dependency between x and the quantileof Y | X = x — for example, when the dependency is linear with steep gradient. Overcoming this bias implies
performing local linear regression.
Let us define a local linear model for the quantile, centered in x:
Qτ (Y | X = x + δ) ' a · δ + q(17)

We want to estimate the constant q of this regression (δ = 0). The problem to solve is then:min 2(q,a)∈RN
X

n=1

wn ρτ (yn − a (xn − x) − q)(18)

We may also consider a quadratic model defined by
min 3(q,a,b)∈R

N
X

n=1



2
wn ρτ yn − a (xn − x) − b (xn − x) − q
5

(19)

5.2

Implementation

The choice of h for the local linear regression is extensively discussed in Yu and Jones [8] and Ruppert,
Sheather and Wand [9]. In practice, for thousands of observations, the parameter h does not have a strong
influence. Yu and Jones propose a rule-of-the-thumb method for the estimation of h in quantile regression
given the optimal h for local O.L.S. of Y on X, noted hmean . They refer to Ruppert, Sheather and Wand[9] for the choice of hmean (This method requires the calculus of the second derivative of E (Y | X = x) inx).
Our procedures only use the formula in Ruppert, Sheather and Wand [9] for hmean , without calculating
the second derivative, and we follow Yu and Jones [8] to choose the optimal bandwidth h. A small correction
is possible via a global variable, but is not often needed.
Results are presented in Figures 1 and 2. We find that the linear regression gives correct results in quasiaffine zones. But when the second derivative is high enough, results are much more questionable. That is
why in this case quadratic regression seems more suitable.

5.3

Beyond the Normal distribution

When we perform a linear regression, we assume that (Y, X) is a gaussian vector. When Y and X are notnormal-distributed but the copula is Normal, linear regression could be performed with some modifications(the regression is done in the Ψ projection space). When copula is not Normal, some preliminary tests showthat local regression gives very good results (in particular for the local quadratic regression). For moredetails, please refer to Costinot, Roncalli and Teiletche [10].

References[1] Gouriéroux, C and A. Monfort [1996], Statistique et Modèles Econométriques, second edition,
Economica, Paris(English translation: Statistics and Econometric Models, Cambridge University Press, Cambridge)[2] Bonnans, J.F., J.C. Gilbert, C. Lemaréchal and C. Sagastizábal [1997], Optimisation Numérique— Aspects théoriques et pratiques, Springer-Verlag, Berlin[3] Koenker, R. and G. Basset [1978], Regression quantiles, Econometrica, 46, 33-50[4] Koenker, R. [2000], Galton, Edgeworth, Frisch, and prospects for quantile regression in econometrics,
Journal of Econometrics, 95, 347-374[5] Portnoy, S. and R. Koenker [1997], The Gaussian hare and the Laplacean tortoise: computabilityof `1 vs `2 regression estimators, Statistical Science, 12, 279-300[6] Buchinsky, M. [1997], Recent advances in quantile regression models: a practical guideline for empiricalresearch, forthcoming in Journal of Human Resources[7] Press, W.H., S.A. Teukolsky, W.T. Vetterling and B.P. Flannery [1992], Numerical Recipes in
Fortran, second edition, Cambridge University Press, Cambridge[8] Yu, K. and M.C. Jones [1998], Local linear quantile regression, Journal of the American Statistical
Association, 93, 228-237[9] Ruppert, D., S.J. Sheather and M.P. Wand [1995], An effective bandwidth selector for local leastsquares regression, Journal of the American Statistical Association, 90, 1257-1270[10] Costinot, A., T. Roncalli and J. Teiletche [2000], Revisiting the dependence between financial
markets with copulas, Groupe de Recherche Opérationnelle, Crédit Lyonnais, Working Paper

6Figure 1: Linear vs quadratic regression (I)Figure 2: Linear vs quadratic regression (II)7

A

The GAUSS Qreg library

A.1

Introduction

A.1.1

Installation

1. The file libQreg.zip is a zipped archive file. Copy this file under the root directory of GAUSS, forexample C:\GAUSS.
2. Unzip it with archive mode. It is automatically recognized by WinZip. With Unzip or PKunzip, use the-d flagpkunzip -d libQreg.zip
Directories will then be created and files will be copied over them:target pathtarget path\examples\qreg
target path\lib
target path\src\qreg

readme.qreg
examples and tutorial files
library filesource code files

3. Run GAUSS. Log on to the src\qreg directory2 and add the path to the library file qreg.lcg in thefollowing way:
lib qreg /addpath
A.1.2

Getting started

Gauss 3.2 for OS/2, Windows NT/95 or Unix is required to use the Qreg routines.
A.1.2.1 The file readme.Qreg The file readme.Qreg contains last minute information on the Qreg
procedures. Please read it before using them.
A.1.2.2 Setup In order to use these procedures, the Qreg library must be active. This is done byincluding Qreg in the LIBRARY statement at the top of your program:library Qreg;
To reset global variables in subsequent executions of the program, the following instruction should be used:
setQreg;
If you plan to make any right-hand reference to the global variables, you will also need the statement:#include target path\src\qreg\qreg.ext;
The Qreg version number is stored as a global variable:
Qreg ver3 × 1 matrix where the first element indicates the major version number, thesecond element the minor version number, and the third element the revision
number
2 You may use the commands ChangeDir or chdir. Note that you can verify that you are in the src\qreg directory with thecdir(0) command.

8A.1.3What is Qreg?

Qreg is a GAUSS library for computing quantile regression. Qreg contains the procedures whose list is given
below. See the command reference part for a full description.
• localQreg: Local Quantile Regression.
• Qreg: Linear Quantile Regression.
• setQreg: Resets the global variables.
• Qreg solveLP1: Solves the dual program using using interior-point method.
• Qreg solveLP2: Solves the dual program using using QP method.
A.1.4

Using Online Help

Qreg library supports Windows Online Help. Before using the browser, you have to verify that the Qreg
library is activated by the library command.

A.2

Command reference

The following global variables and procedures are defined in Qreg. They are the reserved words of Qreg.
localqreg, localqreg, qreg, qreg algr, qreg big, qreg eps, qreg h, qreg maxit, qreg mtd,
qreg printiters, qreg sigma, qreg solvelp1, qreg solvelp2, qreg ver, setqreg

The default global control variables are
Qreg algr
Qreg big
Qreg eps
Qreg hQreg maxit
Qreg mtd
Qreg PrintIters
Qreg sigma

9

1
1020
0.0001150
100.99995

localQreg
Purpose
Local quantile regression.
Formatq = localQreg(Y,X,tau,xstar);
Input
Y
X
tau
xstar
Outputq
GlobalsaltnamoutputQreg algr

Qreg hQreg mtdN × 1 vector, dependent variable
N × 1 vector, independent variable
M × 1 vector, quantile levels
P × 1 vector, quantile points
P × M matrix, estimated quantile Y | X = x?
P × 1 vector, variable names (default = 0)scalar, (default = 1)
1 — print the statistics
0 — no printing
scalar, LP algorithm (default = 1)
1 for the interior-point method
2 for the QP method
scalar, multiplicative factor of the default bandwidth (default = 1)
scalar, regression type (default = 1)
1 for linear regression
2 for quadratic regression

RemarkSee the procedures Qreg SolveLP1 and Qreg SolveLP2 for the optimization step.
Sourcesrc/qreg.src

10

Qreg
PurposeLinear quantile regression.
Format{beta,u plus,u minus} = Qreg(Y,X,tau,w);
Input
Y
X
tau
w
Outputbeta
u plusu minusGlobalsaltnamoutputQreg algr

N × 1 vector, dependent variable
N × K vector, independent variables
M × 1 vector, quantile levels
N × 1 vector, containing weights (0 for uniform weights)(K + 1) × M matrix, estimated coefficients
N × M matrix, positive part of residuals
N × M matrix, negative part of residuals
P × 1 vector, variable names (default = 0)scalar, (default = 1)
1 — print the statistics
0 — no printing
scalar, LP algorithm (default = 1)
1 for the interior-point method
2 for the QP method

RemarkSee the procedures Qreg SolveLP1 and Qreg SolveLP2 for the optimization step.
The linear regression is
Y = β 0 + βX + u>.
and the procedure returns the vector β̂ 0 β̂
Sourcesrc/qreg.src

11

setQreg
PurposeResets the global variables declared in qreg.dec.
FormatsetQreg;
RemarkThe default global control variables are
Qreg algr
Qreg big
Qreg eps
Qreg hQreg maxit
Qreg mtd
Qreg PrintIters
Qreg sigma
Sourcesrc/qreg.src

12

1
1020
0.0001150
100.99995

Qreg solveLP1 & Qreg solveLP2
PurposeSolves the linear program
min c> xxu.c. Ax = b and 0 ≤ x ≤ x+

RemarkWe do not describe these procedures because they are internally used by Qreg and localQreg. But if
you want to use them, do not forget that they returns the dual solution (not the primal solution).
Sourcesrc/qreg.src

13

A.3

Tutorial• This first example shows the use of the different gloval variables.
new;library Qreg,pgraph;
setQreg;cls;
N = 100;
X = rndu(N,2);
Y = 12 + 3*X[.,1] + 5*X[.,2] + .2*rndn(rows(X),1);
tau = 0.05|0.50|0.95|0.75;
output file = qreg1.out reset;_Qreg_algr = 1;/* Interior-point method*/_Qreg_PrintIters = 0; /* Do not print the iterations */__output = 2;/* Print the statistics*/{beta,u_plus,u_minus} = Qreg(Y,X,tau,0);_Qreg_PrintIters = 3; /* Printing every 3 iterations */{beta,u_plus,u_minus} = Qreg(Y,X,tau,0);_Qreg_algr = 2;/* QP method{beta,u_plus,u_minus} = Qreg(Y,X,tau,0);*/__altnam = ’’First’’ | ’’Second’’;/* Use variable names */{beta,u_plus,u_minus} = Qreg(Y,X,tau,0);
output off;

rndseed 123;
N = 1000;
X = 10*rndu(N,1)-5;
Y = 5 + 2*X + rndn(rows(X),1)*10;
tau = 0.05|0.50|0.95|0.75;_Qreg_algr = 1;
{beta,u_plus,u_minus} = Qreg(Y,X,tau,0);
xstar = seqa(-5,10/200,201);q = beta[1,.] + beta[2,.] .* xstar;graphset;
begwind;makewind(9,6.855,0,0,1);
makewind(9,6.855,0,0,1);
fonts(’’simplex simgrma’’);setwind(1);_pdate = 0; _pframe = 0; _pnum = 2;
_plctrl = 15; _pltype = 6; _plwidth = 5; _pstype = 8|9|10|11;xlabel(’’\214X’’); ylabel(’’\214Y’’);xtics(-5,5,1,1);
ytics(-20,30,10,1);_plegstr = ’’\202t\201 = 5%\000\202t\201 = 50%\000\202t\201 = 95%\000\202t\201 = 75%’’;_plegctl = {2 5 6.5 1};xy(xstar,q);_plegctl = 0;
setwind(2);_plctrl = -1; _pstypexy(X,Y);= 3; _psymsiz = 0.4;

14

graphprt(’’-c=1 -cf=qreg1.ps’’);endwind;===============================================================================
Qreg - Linear Quantile Regression
Version 1.0.0
4/27/2001
5:35 pm===============================================================================
Total observations:
Number of variables:100
2

VAR. / tau (in %)5.000
50.00095.00075.000---------------------------------------------------------------CONSTANT
11.7837
11.9274
12.2430
12.0341X01
2.84213.02533.02643.0195X02
4.89945.04035.01905.0483iter. / gap / mu:iter. / gap / mu:iter. / gap / mu:

369

1.8637755
0.01000313
1.4972544e-005

0.009758235
1.3313893e-005
3.4681612e-008

iter. / gap / mu:iter. / gap / mu:

360.21025711
0.00045417086

0.0001474261
3.9935013e-007

iter. / gap / mu:iter. / gap / mu:iter. / gap / mu:

36
93.0758464
0.08261169
5.9193175e-007

0.012127431
0.00014484139
1.0355861e-014

iter. / gap / mu:iter. / gap / mu:

3
60.85150539
0.011686899

0.00045107856
7.0206601e-006===============================================================================
Qreg - Linear Quantile Regression
Version 1.0.0
4/27/2001
5:35 pm===============================================================================
Total observations:
Number of variables:100
2

VAR. / tau (in %)5.000
50.00095.00075.000---------------------------------------------------------------CONSTANT
11.7837
11.9274
12.2430
12.0341X01
2.84213.02533.02643.0195X02
4.89945.04035.01905.0483===============================================================================
Qreg - Linear Quantile Regression
Version 1.0.0
4/27/2001
5:35 pm===============================================================================
Total observations:
Number of variables:100
2

VAR. / tau (in %)5.000
50.00095.00075.000---------------------------------------------------------------CONSTANT
11.7837
11.9274
12.2430
12.0340X01
2.84213.02533.02643.0196X02
4.89945.04035.01905.0485===============================================================================
Qreg - Linear Quantile Regression
Version 1.0.0
4/27/2001
5:35 pm===============================================================================
Total observations:
Number of variables:100
2

VAR. / tau (in %)5.000
50.00095.00075.000---------------------------------------------------------------CONSTANT
11.7837
11.9274
12.2430
12.0340First
2.84213.02533.02643.0196
Second
4.89945.04035.01905.0485• We obtain Figure 1 with the following program:new;library Qreg,pgraph;
setQreg;
N = 1000;
X = rndu(N,1);
Y = sin(9*X) + (rndu(N,1) - 0.5);
tau = 0.2|0.5|0.95;
P = 50;xstar = seqa(0,1/(P-1),P);__output = 2;
_qreg_mtd = 1;
q1 = localQreg(Y,X,tau,xstar);_qreg_mtd = 2;
q2 = localQreg(Y,X,tau,xstar);

15

Figure 3: Linear quantile regression

graphset;
begwind;makewind(9/2,6.855,0,0,1);
makewind(9/2,6.855,0,0,1);
makewind(9/2,6.855,9/2,0,1);
makewind(9/2,6.855,9/2,0,1);_pdate = 0; _pframe = 0; _pnum = 2;
_paxht = 0.25; _pnumht = 0.25; _ptitlht = 0.25; _plwidth = 5;
xlabel(’’\214X’’); ylabel(’’\214Y’’);xtics(0,1,0.2,1);
ytics(-1.5,1.5,0.5,1);
fonts(’’simplex simgrma’’);setwind(1);title(’’\214Linear local regression’’);_pltype = 6|1|3; _plctrl = 0;
_plegstr = ’’\202t\201 = 20%\000\202t\201 = 50%\000\202t\201 = 95%’’;_plegctl = {2 6 6 1};xy(xstar,q1);_plegctl = 0;
setwind(2);_plctrl = -1; _pstypexy(X,Y);= 3; _psymsiz = 0.75;

setwind(3);title(’’\214Quadratic local regression’’);_pltype = 6|1|3; _plctrl = 0;xy(xstar,q2);
setwind(4);_plctrl = -1; _pstype= 3; _psymsiz = 0.5;

16

xy(X,Y);graphprt(’’-c=1 -cf=qreg2.ps’’);endwind;• We obtain Figure 2 with the following program:new;library Qreg,pgraph;
setQreg;__output = 0;
N = 5000;
X = rndu(n, 1);
Y = rndu(rows(x),1) .* (cos(2*pi*X-pi)+1);
tau = 0.95;
P = 50;xstar = seqa(0,1/(p-1),P);_Qreg_mtd = 1;
q1 = localQreg(Y,X,tau,xstar);_Qreg_mtd = 2;
q2 = localQreg(Y,X,tau,xstar);q = q1~q2;
graphset;
begwind;makewind(9,6.855,0,0,1);
makewind(9,6.855,0,0,1);
setwind(1);_pdate = 0; _pframe = 0; _pnum = 2;
_plctrl = 0|5|5; _pltype = 3|6|6; _plwidth = 5;
_pstype = 8|8|9;xlabel(’’\214X’’); ylabel(’’\214Y’’);ytics(0,2,0.5,1);
xtics(0,1,0.2,1);_plegstr = ’’True quantiles\000Local linear regression\000Local quadratic regression’’;_plegctl = {2 4 6 5};xy(xstar,tau*(cos(2*pi*xstar-pi)+1)~q);_plegctl = 0;
setwind(2);_plctrl = -1; _pstypexy(X,Y);= 3; _psymsiz = 0.2;

graphprt(’’-c=1 -cf=qreg3.ps’’);endwind;17