NAG C 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 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 , nag_regsn_quant_linear_iid (g02qfc) 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.
nag_regsn_quant_linear_iid (g02qfc) 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 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:     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:     x[n×m] const doubleInput
Note: where Xi,j appears in this document, it refers to the array element x[i-1×m+j-1].
On entry: X, the design matrix, with the ith value for the jth variate supplied in Xi,j, for i=1,2,,n and j=1,2,,m.
4:     y[n] const doubleInput
On entry: y, the observations on the dependent variable.
5:     ntau IntegerInput
On entry: the number of quantiles of interest.
Constraint: ntau1.
6:     tau[ntau] const doubleInput
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
Constraint: ε<tau[l-1]<1-ε where ε is the machine precision returned by nag_machine_precision (X02AJC), for l=1,2,,ntau.
7:     df double *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:     b[m×ntau] doubleOutput
Note: where Bj,l appears in this document, it refers to the array element b[l-1×m+j-1].
On exit: β^, the estimates of the parameters of the regression model, with Bj,l containing the coefficient for the variable in column j of x, estimated for τ=tau[l-1].
9:     bl[m×ntau] doubleOutput
Note: where BLj,l appears in this document, it refers to the array element bl[l-1×m+j-1].
On exit: β^L, the lower limit of a 95% confidence interval for β^, with BLj,l holding the lower limit associated with Bj,l.
10:   bu[m×ntau] doubleOutput
Note: where BUj,l appears in this document, it refers to the array element bu[l-1×m+j-1].
On exit: β^U, the upper limit of a 95% confidence interval for β^, with BUj,l holding the upper limit associated with Bj,l.
11:   info[ntau] IntegerOutput
On exit: info[l] holds additional information concerning the model fitting and confidence limit calculations when τ=tau[l].
Code Warning
0 Model fitted and confidence limits calculated successfully.
1 The function 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 function 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:   fail NagError *Input/Output
The NAG error argument (see Section 3.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 value had an illegal value.
NE_INT
On entry, n=value.
Constraint: n2.
On entry, ntau=value.
Constraint: ntau1.
NE_INT_2
On entry, m=value and n=value.
Constraint: 1m<n.
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.
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, tau[value]=value.
Constraint: ε<tau[l-1]<1-ε where ε is the machine precision returned by nag_machine_precision (X02AJC), for all ntau.
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.

9
Further Comments

Calling nag_regsn_quant_linear_iid (g02qfc) is equivalent to calling nag_regsn_quant_linear (g02qgc) 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 (g02qfce.c)

10.2
Program Data

Program Data (g02qfce.d)

10.3
Program Results

Program Results (g02qfce.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