NAG Library Routine Document

g02qff (quantile_linreg_easy)

1
Purpose

g02qff performs a multiple linear quantile regression, returning the parameter estimates and associated confidence limits based on an assumption of Normal, independent, identically distributed errors. g02qff is a simplified version of g02qgf.

2
Specification

Fortran Interface
Subroutine g02qff ( n, m, x, y, ntau, tau, df, b, bl, bu, info, ifail)
Integer, Intent (In):: n, m, ntau
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: info(ntau)
Real (Kind=nag_wp), Intent (In):: x(n,m), y(n), tau(ntau)
Real (Kind=nag_wp), Intent (Out):: df, b(m,ntau), bl(m,ntau), bu(m,ntau)
C Header Interface
#include <nagmk26.h>
void  g02qff_ (const Integer *n, const Integer *m, const double x[], const double y[], const Integer *ntau, const double tau[], double *df, double b[], double bl[], double bu[], Integer info[], Integer *ifail)

3
Description

Given a vector of n observed values, y = y i : i = 1, 2, , n , an n×p design matrix X, a column vector, x, of length p holding the ith row of X and a quantile τ 0 , 1 , g02qff estimates the p-element vector β as the solution to
minimize β p i=1 n ρ τ y i - xiT β (1)
where ρ τ  is the piecewise linear loss function ρ τ z = z τ - I z < 0 , and I z < 0  is an indicator function taking the value 1 if z<0 and 0 otherwise.
g02qff assumes Normal, independent, identically distributed (IID) errors and calculates the asymptotic covariance matrix from
Σ = τ 1 - τ n s τ 2 XT X -1  
where s is the sparsity function, which is estimated from the residuals, ri = yi - xiT β^  (see Koenker (2005)).
Given an estimate of the covariance matrix, Σ^, lower, β^L, and upper, β^U, limits for a 95% confidence interval are calculated for each of the p parameters, via
β^ Li = β^ i - t n-p , 0.975 Σ^ ii , β^ Ui = β^ i + t n-p , 0.975 Σ^ ii  
where tn-p,0.975 is the 97.5 percentile of the Student's t distribution with n-k degrees of freedom, where k is the rank of the cross-product matrix XTX.
Further details of the algorithms used by g02qff can be found in the documentation for g02qgf.

4
References

Koenker R (2005) Quantile Regression Econometric Society Monographs, Cambridge University Press, New York

5
Arguments

1:     n – IntegerInput
On entry: n, the number of observations in the dataset.
Constraint: n2.
2:     m – IntegerInput
On entry: p, the number of variates in the model.
Constraint: 1m<n.
3:     xnm – Real (Kind=nag_wp) arrayInput
On entry: X, the design matrix, with the ith value for the jth variate supplied in xij, for i=1,2,,n and j=1,2,,m.
4:     yn – Real (Kind=nag_wp) arrayInput
On entry: y, the observations on the dependent variable.
5:     ntau – IntegerInput
On entry: the number of quantiles of interest.
Constraint: ntau1.
6:     tauntau – Real (Kind=nag_wp) arrayInput
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
Constraint: ε<taul<1-ε where ε is the machine precision returned by x02ajf, for l=1,2,,ntau.
7:     df – Real (Kind=nag_wp)Output
On exit: the degrees of freedom given by n-k, where n is the number of observations and k is the rank of the cross-product matrix XTX.
8:     bmntau – Real (Kind=nag_wp) arrayOutput
On exit: β^, the estimates of the parameters of the regression model, with bjl containing the coefficient for the variable in column j of x, estimated for τ=taul.
9:     blmntau – Real (Kind=nag_wp) arrayOutput
On exit: β^L, the lower limit of a 95% confidence interval for β^, with bljl holding the lower limit associated with bjl.
10:   bumntau – Real (Kind=nag_wp) arrayOutput
On exit: β^U, the upper limit of a 95% confidence interval for β^, with bujl holding the upper limit associated with bjl.
11:   infontau – Integer arrayOutput
On exit: infol holds additional information concerning the model fitting and confidence limit calculations when τ=taul.
Code Warning
0 Model fitted and confidence limits calculated successfully.
1 The routine did not converge whilst calculating the parameter estimates. The returned values are based on the estimate at the last iteration.
2 A singular matrix was encountered during the optimization. The model was not fitted for this value of τ.
8 The routine did not converge whilst calculating the confidence limits. The returned limits are based on the estimate at the last iteration.
16 Confidence limits for this value of τ could not be calculated. The returned upper and lower limits are set to a large positive and large negative value respectively.
It is possible for multiple warnings to be applicable to a single model. In these cases the value returned in info is the sum of the corresponding individual nonzero warning codes.
12:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=11
On entry, n=value.
Constraint: n2.
ifail=21
On entry, m=value and n=value.
Constraint: 1m<n.
ifail=51
On entry, ntau=value.
Constraint: ntau1.
ifail=61
On entry, tauvalue=value.
Constraint: ε<taul<1-ε where ε is the machine precision returned by x02ajf, for all ntau.
ifail=111
A potential problem occurred whilst fitting the model(s).
Additional information has been returned in info.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

g02qff is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02qff makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9
Further Comments

Calling g02qff is equivalent to calling g02qgf with

10
Example

A quantile regression model is fitted to Engels 1857 study of household expenditure on food. The model regresses the dependent variable, household food expenditure, against household income. An intercept is included in the model by augmenting the dataset with a column of ones.

10.1
Program Text

Program Text (g02qffe.f90)

10.2
Program Data

Program Data (g02qffe.d)

10.3
Program Results

Program Results (g02qffe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 500 1000 1500 2000 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 Household Food Expenditure Household Income Example Program Quantile Regression - Simple Interface Engels 1857 Study of Household Expenditure on Food gnuplot_plot_1 gnuplot_plot_2 τ = 0.10 gnuplot_plot_3 τ = 0.25 gnuplot_plot_4 τ = 0.50 gnuplot_plot_5 τ = 0.75 gnuplot_plot_6 τ = 0.90