NAG Library Function Document
nag_regsn_quant_linear_iid (g02qfc)
1 Purpose
nag_regsn_quant_linear_iid (g02qfc) performs a multiple linear quantile regression, returning the parameter estimates and associated confidence limits based on an assumption of Normal, independent, identically distributed errors. nag_regsn_quant_linear_iid (g02qfc) is a simplified version of
nag_regsn_quant_linear (g02qgc).
2 Specification
#include <nag.h> |
#include <nagg02.h> |
void |
nag_regsn_quant_linear_iid (Integer n,
Integer m,
const double x[],
const double y[],
Integer ntau,
const double tau[],
double *df,
double b[],
double bl[],
double bu[],
Integer info[],
NagError *fail) |
|
3 Description
Given a vector of
observed values,
, an
design matrix
, a column vector,
, of length
holding the
th row of
and a quantile
, nag_regsn_quant_linear_iid (g02qfc) 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.
nag_regsn_quant_linear_iid (g02qfc) 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 nag_regsn_quant_linear_iid (g02qfc) can be found in the documentation for
nag_regsn_quant_linear (g02qgc).
4 References
Koenker R (2005) Quantile Regression Econometric Society Monographs, Cambridge University Press, New York
5 Arguments
- 1:
– IntegerInput
-
On entry: , the number of observations in the dataset.
Constraint:
.
- 2:
– IntegerInput
-
On entry: , the number of variates in the model.
Constraint:
.
- 3:
– const doubleInput
-
Note: where appears in this document, it refers to the array element
.
On entry: , the design matrix, with the
th value for the th variate supplied in , for and .
- 4:
– const doubleInput
-
On entry: , the observations on the dependent variable.
- 5:
– IntegerInput
-
On entry: the number of quantiles of interest.
Constraint:
.
- 6:
– const doubleInput
-
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
Constraint:
where
is the
machine precision returned by
nag_machine_precision (X02AJC), for
.
- 7:
– double *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:
– doubleOutput
-
Note: where appears in this document, it refers to the array element
.
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:
– doubleOutput
-
Note: where appears in this document, it refers to the array element
.
On exit: , the lower limit of a confidence interval for , with holding the lower limit associated with .
- 10:
– doubleOutput
-
Note: where appears in this document, it refers to the array element
.
On exit: , the upper limit of a confidence interval for , with holding the upper limit associated with .
- 11:
– IntegerOutput
-
On exit:
holds additional information concerning the model fitting and confidence limit calculations when
.
Code | Warning |
| Model fitted and confidence limits calculated successfully. |
| The function 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 function 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:
– NagError *Input/Output
-
The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
- NE_REAL_ARRAY
-
On entry, is invalid.
- NW_POTENTIAL_PROBLEM
-
A potential problem occurred whilst fitting the model(s).
Additional information has been returned in
info.
7 Accuracy
Not applicable.
8 Parallelism and Performance
nag_regsn_quant_linear_iid (g02qfc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_regsn_quant_linear_iid (g02qfc) 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
Calling nag_regsn_quant_linear_iid (g02qfc) is equivalent to calling
nag_regsn_quant_linear (g02qgc) with
- , ,
-
no weights supplied, i.e., wt set to NULL,
- ,
- 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
Program Text (g02qfce.c)
10.2 Program Data
Program Data (g02qfce.d)
10.3 Program Results
Program Results (g02qfce.r)