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

# Syntax

C#
```public static void g02qf(
int n,
int m,
double[,] x,
double[] y,
int ntau,
double[] tau,
out double df,
double[,] b,
double[,] bl,
double[,] bu,
int[] info,
out int ifail
)```
Visual Basic
```Public Shared Sub g02qf ( _
n As Integer, _
m As Integer, _
x As Double(,), _
y As Double(), _
ntau As Integer, _
tau As Double(), _
<OutAttribute> ByRef df As Double, _
b As Double(,), _
bl As Double(,), _
bu As Double(,), _
info As Integer(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02qf(
int n,
int m,
array<double,2>^ x,
array<double>^ y,
int ntau,
array<double>^ tau,
[OutAttribute] double% df,
array<double,2>^ b,
array<double,2>^ bl,
array<double,2>^ bu,
array<int>^ info,
[OutAttribute] int% ifail
)```
F#
```static member g02qf :
n : int *
m : int *
x : float[,] *
y : float[] *
ntau : int *
tau : float[] *
df : float byref *
b : float[,] *
bl : float[,] *
bu : float[,] *
info : int[] *
ifail : int byref -> unit
```

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the number of observations in the dataset.
Constraint: ${\mathbf{n}}\ge 2$.
m
Type: System..::..Int32
On entry: $p$, the number of variates in the model.
Constraint: $1\le {\mathbf{m}}<{\mathbf{n}}$.
x
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [n, m]
On entry: $X$, the design matrix, with the $\mathit{i}$th value for the $\mathit{j}$th variate supplied in ${\mathbf{x}}\left[\mathit{i}-1,\mathit{j}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{m}}$.
y
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: $y$, observations on the dependent variable.
ntau
Type: System..::..Int32
On entry: the number of quantiles of interest.
Constraint: ${\mathbf{ntau}}\ge 1$.
tau
Type: array<System..::..Double>[]()[][]
An array of size [ntau]
On entry: the vector of quantiles of interest. A separate model is fitted to each quantile.
Constraint: $\sqrt{\epsilon }<{\mathbf{tau}}\left[\mathit{l}-1\right]<1-\sqrt{\epsilon }$ where $\epsilon$ is the machine precision returned by x02aj, for $\mathit{l}=1,2,\dots ,{\mathbf{ntau}}$.
df
Type: System..::..Double%
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 ${X}^{\mathrm{T}}X$.
b
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [m, ntau]
On exit: $\stackrel{^}{\beta }$, the estimates of the parameters of the regression model, with ${\mathbf{b}}\left[j-1,l-1\right]$ containing the coefficient for the variable in column $j$ of x, estimated for $\tau ={\mathbf{tau}}\left[l-1\right]$.
bl
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [m, ntau]
On exit: ${\stackrel{^}{\beta }}_{L}$, the lower limit of a $95%$ confidence interval for $\stackrel{^}{\beta }$, with ${\mathbf{bl}}\left[j-1,l-1\right]$ holding the lower limit associated with ${\mathbf{b}}\left[j-1,l-1\right]$.
bu
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [m, ntau]
On exit: ${\stackrel{^}{\beta }}_{U}$, the upper limit of a $95%$ confidence interval for $\stackrel{^}{\beta }$, with ${\mathbf{bu}}\left[j-1,l-1\right]$ holding the upper limit associated with ${\mathbf{b}}\left[j-1,l-1\right]$.
info
Type: array<System..::..Int32>[]()[][]
An array of size [${\mathbf{ntau}}$]
On exit: ${\mathbf{info}}\left[l\right]$ holds additional information concerning the model fitting and confidence limit calculations when $\tau ={\mathbf{tau}}\left[l\right]$.
 Code Warning $0$ Model fitted and confidence limits calculated successfully. $1$ The method 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 $\tau$. $8$ The method 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 $\tau$ 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.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

Given a vector of $n$ observed values, $y=\left\{{y}_{i}:i=1,2,\dots ,n\right\}$, an $n×p$ design matrix $X$, a column vector, $x$, of length $p$ holding the $i$th row of $X$ and a quantile $\tau \in \left(0,1\right)$, g02qf estimates the $p$-element vector $\beta$ as the solution to
 $minimizeβ∈ℝp∑ i=1 n ρτyi-xiTβ$ (1)
where ${\rho }_{\tau }$ is the piecewise linear loss function ${\rho }_{\tau }\left(z\right)=z\left(\tau -I\left(z<0\right)\right)$, and $I\left(z<0\right)$ is an indicator function taking the value $1$ if $z<0$ and $0$ otherwise.
g02qf assumes Normal, independent, identically distributed (IID) errors and calculates the asymptotic covariance matrix from
 $Σ=τ1-τnsτ2XTX-1$
where $s$ is the sparsity function, which is estimated from the residuals, ${r}_{i}={y}_{i}-{x}_{i}^{\mathrm{T}}\stackrel{^}{\beta }$ (see Koenker (2005)).
Given an estimate of the covariance matrix, $\stackrel{^}{\Sigma }$, lower, ${\stackrel{^}{\beta }}_{L}$, and upper, ${\stackrel{^}{\beta }}_{U}$, limits for a $95%$ confidence interval are calculated for each of the $p$ parameters, via
 $β^Li=β^i-tn-p,0.975Σ^ii,β^Ui=β^i+tn-p,0.975Σ^ii$
where ${t}_{n-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 ${X}^{\mathrm{T}}X$.
Further details of the algorithms used by g02qf can be found in the documentation for g02qg.

# References

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

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=11$
On entry, ${\mathbf{n}}<2$.
${\mathbf{ifail}}=21$
 On entry, ${\mathbf{m}}<1$, or ${\mathbf{m}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=51$
On entry, ${\mathbf{ntau}}<1$.
${\mathbf{ifail}}=61$
On entry, tau is invalid.
${\mathbf{ifail}}=111$
On exit, problems were encountered whilst fitting at least one model. Additional information has been returned in info.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Not applicable.

# Parallelism and Performance

None.

Calling g02qf is equivalent to calling g02qg with
• ${\mathbf{rcord}}=2$,
• ${\mathbf{rcord}}=1$, ${\mathbf{ic1}}=\text{"N"}$,
• $\mathbf{_weight}=\text{"U"}$,
• ${\mathbf{lddat}}={\mathbf{n}}$,
• setting each element of isx to $1$,
• ${\mathbf{ip}}={\mathbf{m}}$,
• ${\mathbf{Interval Method}}='\mathrm{IID}'$, and
• ${\mathbf{Significance Level}}=0.95$.

# 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.

Example program (C#): g02qfe.cs

Example program data: g02qfe.d

Example program results: g02qfe.r