NAG FL Interface
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 <nag.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) |
|
C++ Header Interface
#include <nag.h> extern "C" {
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) |
}
|
The routine may be called by the names g02qff or nagf_correg_quantile_linreg_easy.
3
Description
Given a vector of
observed values,
, an
design matrix
, a column vector,
, of length
holding the
th row of
and a quantile
,
g02qff 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.
g02qff assumes Normal, independent, identically distributed (IID) errors and calculates the asymptotic covariance matrix from
where
is the sparsity function, which is estimated from the residuals,
(see
Koenker (2005)).
Given an estimate of the covariance matrix,
, lower,
, and upper,
, limits for a
confidence interval are calculated for each of the
parameters, via
where
is the
percentile of the Student's
distribution with
degrees of freedom, where
is the rank of the cross-product matrix
.
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:
– Integer
Input
-
On entry: , the number of observations in the dataset.
Constraint:
.
-
2:
– Integer
Input
-
On entry: , the number of variates in the model.
Constraint:
.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: , the design matrix, with the
th value for the th variate supplied in , for and .
-
4:
– Real (Kind=nag_wp) array
Input
-
On entry: , the observations on the dependent variable.
-
5:
– Integer
Input
-
On entry: the number of quantiles of interest.
Constraint:
.
-
6:
– Real (Kind=nag_wp) array
Input
-
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
Constraint:
where
is the
machine precision returned by
x02ajf, for
.
-
7:
– Real (Kind=nag_wp)
Output
-
On exit: the degrees of freedom given by , where is the number of observations and is the rank of the cross-product matrix .
-
8:
– Real (Kind=nag_wp) array
Output
-
On exit:
, the estimates of the parameters of the regression model, with
containing the coefficient for the variable in column
of
x, estimated for
.
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit: , the lower limit of a confidence interval for , with holding the lower limit associated with .
-
10:
– Real (Kind=nag_wp) array
Output
-
On exit: , the upper limit of a confidence interval for , with holding the upper limit associated with .
-
11:
– Integer array
Output
-
On exit:
holds additional information concerning the model fitting and confidence limit calculations when
.
Code | Warning |
| Model fitted and confidence limits calculated successfully. |
| The routine did not converge whilst calculating the parameter estimates. The returned values are based on the estimate at the last iteration. |
| A singular matrix was encountered during the optimization. The model was not fitted for this value of . |
| The routine did not converge whilst calculating the confidence limits. The returned limits are based on the estimate at the last iteration. |
| 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:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface 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).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry,
.
Constraint:
where
is the
machine precision returned by
x02ajf, for all
ntau.
-
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
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface 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.
Calling
g02qff is equivalent to calling
g02qgf with
- ,
- ,
-
,
- ,
- setting each element of isx to ,
- ,
- , and
- .
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
10.2
Program Data
10.3
Program Results