Note: before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.
Note:this routine usesoptional parametersto define choices in the problem specification and in the details of the algorithm. If you wish to use default settings for all of the optional parameters, you need only read Sections 1 to 10 of this document. If, however, you wish to reset some or all of the settings please refer to Section 11 for a detailed description of the algorithm, to Section 12 for a detailed description of the specification of the optional parameters and to Section 13 for a detailed description of the monitoring information produced by the routine.
G02QGF performs a multiple linear quantile regression. Parameter estimates and, if required, confidence limits, covariance matrices and residuals are calculated. G02QGF may be used to perform a weighted quantile regression. A simplified interface for G02QGF is provided by G02QFF.
Given a vector of observed values,
, an design matrix , a column vector, , of length holding the th row of and a quantile , G02QGF estimates the -element vector as the solution to
where is the piecewise linear loss function , and is an indicator function taking the value if and otherwise. Weights can be incorporated by replacing and with and respectively, where is an diagonal matrix. Observations with zero weights can either be included or excluded from the analysis; this is in contrast to least squares regression where such observations do not contribute to the objective function and are therefore always dropped.
where is a bandwidth and denotes the parameter estimates obtained from a quantile regression using the th quantile. Similarly with .
The last method uses bootstrapping to either estimate a covariance matrix or obtain confidence intervals for the parameter estimates directly. This method therefore does not assume Normally distributed errors. Samples of size are taken from the paired data (i.e., the independent and dependent variables are sampled together). A quantile regression is then fitted to each sample resulting in a series of bootstrap estimates for the model parameters, . A covariance matrix can then be calculated directly from this series of values. Alternatively, confidence limits, and , can be obtained directly from the and sample quantiles of the bootstrap estimates.
Further details of the algorithms used to calculate the covariance matrices can be found in Section 11.
All three asymptotic estimates of the covariance matrix require a bandwidth, . Two alternative methods for determining this are provided:
for a user-supplied value ,
G02QGF allows optional arguments to be supplied via the IOPTS and OPTS arrays (see Section 12 for details of the available options).
to calling G02QGF the optional parameter arrays,
IOPTS and OPTS
must be initialized by calling G02ZKF with OPTSTR set to (see Section 12 for details on the available options). If bootstrap confidence limits are required () then one of the random number initialization routines G05KFF (for a repeatable analysis) or G05KGF (for an unrepeatable analysis) must also have been previously called.
Koenker R (2005) Quantile Regression Econometric Society Monographs, Cambridge University Press, New York
Mehrotra S (1992) On the implementation of a primal-dual interior point method SIAM J. Optim.2 575–601
Nocedal J and Wright S J (1999) Numerical Optimization Springer Series in Operations Research, Springer, New York
Portnoy S and Koenker R (1997) The Gaussian hare and the Laplacian tortoise: computability of squared-error versus absolute error estimators Statistical Science4 279–300
Powell J L (1991) Estimation of monotonic regression models under quantile restrictions Nonparametric and Semiparametric Methods in Econometrics Cambridge University Press, Cambridge
1: – INTEGERInput
On entry: determines the storage order of variates supplied in DAT.
2: – CHARACTER(1)Input
On entry: indicates whether an intercept will be included in the model. The intercept is included by adding a column of ones as the first column in the design matrix, .
An intercept will be included in the model.
An intercept will not be included in the model.
3: – CHARACTER(1)Input
On entry: indicates if weights are to be used.
A weighted regression model is fitted to the data using weights supplied in array WT.
An unweighted regression model is fitted to the data and array WT is not referenced.
4: – INTEGERInput
On entry: the total number of observations in the dataset. If no weights are supplied, or no zero weights are supplied or observations with zero weights are included in the model then . Otherwise the number of observations with zero weights.
5: – INTEGERInput
On entry: , the total number of variates in the dataset.
6: – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array DAT
must be at least
if and at least if .
On entry: the
th value for the th variate, for and , must be supplied in
On entry: , the number of independent variables in the model, including the intercept, see INTCPT, if present.
if , ;
if , .
10: – REAL (KIND=nag_wp) arrayInput
On entry: , the observations on the dependent variable.
11: – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array WT
must be at least
On entry: if , WT must contain the diagonal elements of the weight matrix . Otherwise WT is not referenced.
If , the th observation is not included in the model, in which case the effective number of observations, , is the number of observations with nonzero weights. If , the values of RES will be set to zero for observations with zero weights.
All observations are included in the model and the effective number of observations is N, i.e., .
If , , for ;
The effective number of observations .
12: – INTEGERInput
On entry: the number of quantiles of interest.
13: – REAL (KIND=nag_wp) arrayInput
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
where is the machine precision returned by X02AJF, for .
14: – REAL (KIND=nag_wp)Output
On exit: the degrees of freedom given by , where is the effective number of observations and is the rank of the cross-product matrix .
15: – REAL (KIND=nag_wp) arrayInput/Output
On entry: if ,
must hold an initial estimates for , for and . If , B need not be set.
On exit: , for , contains the estimates of the parameters of the regression model, , estimated for .
If , will contain the estimate corresponding to the intercept and will contain the coefficient of the th variate contained in DAT, where is the th nonzero value in the array ISX.
If , will contain the coefficient of the th variate contained in DAT, where is the th nonzero value in the array ISX.
16: – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array BL
must be at least
On exit: if , contains the lower limit of an confidence interval for
, for and .
Note: the last dimension of the array CH
must be at least
if and and at least if , or and .
On exit: depending on the supplied optional parameters, CH will either not be referenced, hold an estimate of the upper triangular part of the covariance matrix, , or an estimate of the upper triangular parts of and .
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array must be the same array passed as argument IOPTS in the previous call to G02ZKF.
On entry: optional parameter array, as initialized by a call to G02ZKF.
21: – REAL (KIND=nag_wp) arrayCommunication Array
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array must be the same array passed as argument OPTS in the previous call to G02ZKF.
On entry: optional parameter array, as initialized by a call to G02ZKF.
22: – INTEGER arrayCommunication Array
Note: the actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
The actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
If , STATE contains information about the selected random number generator. Otherwise STATE is not referenced.
23: – INTEGER arrayOutput
On exit: holds additional information concerning the model fitting and confidence limit calculations when .
Model fitted and confidence limits (if requested) calculated successfully
The routine did not converge. The returned values are based on the estimate at the last iteration. Try increasing Iteration Limit whilst calculating the parameter estimates or relaxing the definition of convergence by increasing Tolerance.
A singular matrix was encountered during the optimization. The model was not fitted for this value of .
Some truncation occurred whilst calculating the confidence limits for this value of . See Section 11 for details. The returned upper and lower limits may be narrower than specified.
The routine did not converge whilst calculating the confidence limits. The returned limits are based on the estimate at the last iteration. Try increasing Iteration Limit.
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 as defined by the optional parameter Big.
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.
24: – INTEGERInput/Output
On entry: IFAIL must be set to , . 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 is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, if you are not familiar with this argument, the recommended value is . When the value is used it is essential to test the value of IFAIL on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6 Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by X04AAF).
On entry, either the option arrays have not been initialized or they have been corrupted.
On entry, STATE vector has been corrupted or not initialized.
A potential problem occurred whilst fitting the model(s). Additional information has been returned in INFO.
An unexpected error has been triggered by this routine. Please
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
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.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.
8 Parallelism and Performance
G02QGF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G02QGF 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
G02QGF allocates internally approximately the following elements of real storage:
. If then a further
elements are required, and this increases by
if . Where possible, any user-supplied output arrays are used as workspace and so the amount actually allocated may be less. If , , and an internal copy of the input data is avoided and the amount of locally allocated memory is reduced by .
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 two explanatory variables, a column of ones and household income. The model is fit for five different values of and the covariance matrix is estimated assuming Normal IID errors. Both the covariance matrix and the residuals are returned.
In this section a brief description of the interior point algorithm used to estimate the model parameters is presented. It should be noted that there are some differences in the equations given here – particularly (7) and (9) – compared to those given in Koenker (2005) and Portnoy and Koenker (1997).
11.1.1 Central path
Rather than optimize (4) directly, an additional slack variable is added and the constraint is replaced with , for .
The positivity constraint on and is handled using the logarithmic barrier function
The primal-dual form of the problem is used giving the Lagrangian
whose central path is described by the following first order conditions
where denotes the diagonal matrix with diagonal elements given by , similarly with and . By enforcing the inequalities on and strictly, i.e., and for all we ensure that and are positive definite diagonal matrices and hence and exist.
Rather than applying Newton's method to the system of equations given in (5) to obtain the step directions and , Mehrotra substituted the steps directly into (5) giving the augmented system of equations
where and denote the diagonal matrices with diagonal elements given by and respectively.
11.1.2 Affine scaling step
The affine scaling step is constructed by setting in (5) and applying Newton's method to obtain an intermediate set of step directions
Initial step sizes for the primal () and dual () parameters are constructed as
where is a user-supplied scaling factor. If
then the nonlinearity adjustment, described in Section 11.1.3, is not made and the model parameters are updated using the current step size and directions.
11.1.3 Nonlinearity Adjustment
In the nonlinearity adjustment step a new estimate of is obtained by letting
and estimating as
This estimate, along with the nonlinear terms (, , and ) from (6) are calculated using the values of
and obtained from the affine scaling step.
Given an updated estimate for and the nonlinear terms the system of equations
are solved and updated values for
11.1.4 Update and convergence
At each iteration the model parameters
are updated using step directions,
and step lengths
Convergence is assessed using the duality gap, that is, the differences between the objective function in the primal and dual formulations. For any feasible point
the duality gap can be calculated from equations (2) and (3) as
and the optimization terminates if the duality gap is smaller than the tolerance supplied in the optional parameter Tolerance.
11.1.5 Additional information
Initial values are required for the parameters and . If not supplied by the user, initial values for are calculated from a least squares regression of on . This regression is carried out by first constructing the cross-product matrix and then using a pivoted decomposition as performed by F08BFF (DGEQP3). In addition, if the cross-product matrix is not of full rank, a rank reduction is carried out and, rather than using the full design matrix, , a matrix formed from the first -rank columns of is used instead, where is the pivot matrix used during the decomposition. Parameter estimates, confidence intervals and the rows and columns of the matrices returned in the argument CH (if any) are set to zero for variables dropped during the rank-reduction. The rank reduction step is performed irrespective of whether initial values are supplied by the user.
Once initial values have been obtained for , the initial values for and are calculated from the residuals. If then a value of is used instead, where is supplied in the optional parameter Epsilon. The initial values for the and are always set to and respectively.
The solution for in both (7) and (9) is obtained using a Bunch–Kaufman decomposition, as implemented in F07MDF (DSYTRF).
11.2 Calculation of Covariance Matrix
G02QGF supplies four methods to calculate the covariance matrices associated with the parameter estimates for . This section gives some additional detail on three of the algorithms, the fourth, (which uses bootstrapping), is described in Section 3.
Independent, identically distributed (IID) errors
When assuming IID errors, the covariance matrices depend on the sparsity, , which G02QGF estimates as follows:
Let denote the residuals from the original quantile regression, that is
Drop any residual where is less than , supplied in the optional parameter Epsilon.
Sort and relabel the remaining residuals in ascending order, by absolute value, so that
Select the first values where , for some bandwidth .
Sort and relabel these residuals again, so that
and regress them against a design matrix with two columns () and rows given by
using quantile regression with .
Use the resulting estimate of the slope as an estimate of the sparsity.
When using the Powell Sandwich to estimate the matrix , the quantity
is calculated. Dependent on the value of and the method used to calculate the bandwidth (), it is possible for the quantities to be too large or small, compared to machine precision (). More specifically, when , or , a warning flag is raised in INFO, the value is truncated to or respectively and the covariance matrix calculated as usual.
The Hendricks–Koenker Sandwich requires the calculation of the quantity
As with the Powell Sandwich, in cases where , or , a warning flag is raised in INFO, the value truncated to or respectively and the covariance matrix calculated as usual.
In addition, it is required that , in this method. Hence, instead of using
in the calculation of ,
is used instead, where is supplied in the optional parameter Epsilon.
12 Optional Parameters
Several optional parameters in G02QGF control aspects of the optimization algorithm, methodology used, logic or output. Their values are contained in the arrays IOPTS and OPTS; these must be initialized before calling G02QGF by first calling G02ZKF with OPTSTR set to .
Each optional parameter has an associated default value; to set any of them to a non-default value, use G02ZKF. The current value of an optional parameter can be queried using G02ZLF.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in Section 12.1.
intervals are calculated. That is, the covariance matrix, is calculated from the bootstrap estimates and the limits calculated as where is the percentage point from a Student's distribution on degrees of freedom, is the effective number of observations and is given by the optional parameter Significance Level.
Quantile intervals are calculated. That is, the upper and lower limits are taken as the and quantiles of the bootstrap estimates, as calculated using G01AMF.
The number of bootstrap samples used to calculate the confidence limits and covariance matrix (if requested) when .
If and , then the parameter estimates for each of the bootstrap samples are displayed. This information is sent to the unit number specified by Unit Number.
Calculate Initial Values
If then the initial values for the regression parameters, , are calculated from the data. Otherwise they must be supplied in B.
This special keyword is used to reset all optional parameters to their default values.
Drop Zero Weights
If a weighted regression is being performed and then observations with zero weight are dropped from the analysis. Otherwise such observations are included.
, the tolerance used when calculating the covariance matrix and the initial values for and . For additional details see Section 11.2 and Section 11.1.5 respectively.
The value of Interval Method controls whether confidence limits are returned in BL and BU and how these limits are calculated. This parameter also controls how the matrices returned in CH are calculated.
No limits are calculated and BL, BU and CH are not referenced.
The Powell Sandwich method with a Gaussian kernel is used.
The Hendricks–Koenker Sandwich is used.
The errors are assumed to be identical, and independently distributed.
A bootstrap method is used, where sampling is done on the pair . The number of bootstrap samples is controlled by the parameter Bootstrap Iterations and the type of interval constructed from the bootstrap samples is controlled by Bootstrap Interval Method.
, , , or .
The maximum number of iterations to be performed by the interior point optimization algorithm.
The value of Matrix Returned controls the type of matrices returned in CH. If , this parameter is ignored and CH is not referenced. Otherwise:
No matrices are returned and CH is not referenced.
The covariance matrices are returned.
If or , the matrices and are returned. Otherwise no matrices are returned and CH is not referenced.
The matrices returned are calculated as described in Section 3, with the algorithm used specified by Interval Method. In the case of the covariance matrix is calculated directly from the bootstrap estimates.
, or .
If then the duality gap is displayed at each iteration of the interior point optimization algorithm. In addition, the final estimates for are also displayed.
The monitoring information is sent to the unit number specified by Unit Number.
The tolerance used to calculate the rank, , of the cross-product matrix, . Letting be the orthogonal matrix obtained from a decomposition of , then the rank is calculated by comparing with .
If the cross-product matrix is rank deficient, then the parameter estimates for the columns with the smallest values of are set to zero, along with the corresponding entries in BL, BU and CH, if returned. This is equivalent to dropping these variables from the model. Details on the decomposition used can be found in F08BFF (DGEQP3).
If , the residuals are returned in RES. Otherwise RES is not referenced.
The scaling factor used when calculating the affine scaling step size (see equation (8)).
, the size of the confidence interval whose limits are returned in BL and BU.
Convergence tolerance. The optimization is deemed to have converged if the duality gap is less than Tolerance (see Section 11.1.4).