NAG Library Routine Document
G02DFF
1 Purpose
G02DFF deletes an independent variable from a general linear regression model.
2 Specification
INTEGER 
IP, LDQ, INDX, IFAIL 
REAL (KIND=nag_wp) 
Q(LDQ,IP+1), RSS, WK(2*IP) 

3 Description
When selecting a linear regression model it is sometimes useful to drop independent variables from the model and to examine the resulting submodel. G02DFF updates the
$QR$ decomposition used in the computation of the linear regression model. The
$QR$ decomposition may come from
G02DAF or
G02DEF, or a previous call to G02DFF.
For the general linear regression model with
$p$ independent variables fitted
G02DAF or
G02DEF compute a
$QR$ decomposition of the (weighted) independent variables and form an upper triangular matrix
$R$ and a vector
$c$. To remove an independent variable
$R$ and
$c$ have to be updated. The column of
$R$ corresponding to the variable to be dropped is removed and the matrix is then restored to upper triangular form by applying a series of Givens rotations. The rotations are then applied to
$c$. Note only the first
$p$ elements of
$c$ are affected.
The method used means that while the updated values of
$R$ and
$c$ are computed an updated value of
$Q$ from the
$QR$ decomposition is not available so a call to
G02DEF cannot be made after a call to G02DFF.
G02DDF can be used to calculate the parameter estimates,
$\hat{\beta}$, from the information provided by G02DFF.
4 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
5 Arguments
 1: $\mathrm{IP}$ – INTEGERInput

On entry: $p$, the number of independent variables already in the model.
Constraint:
${\mathbf{IP}}\ge 1$.
 2: $\mathrm{Q}\left({\mathbf{LDQ}},{\mathbf{IP}}+1\right)$ – REAL (KIND=nag_wp) arrayInput/Output

On entry: the results of the
$QR$ decomposition as returned by routines
G02DAF,
G02DCF,
G02DEF or
G02EEF, or previous calls to G02DFF.
On exit: the updated $QR$ decomposition.
 3: $\mathrm{LDQ}$ – INTEGERInput

On entry: the first dimension of the array
Q as declared in the (sub)program from which G02DFF is called.
Constraint:
${\mathbf{LDQ}}\ge {\mathbf{IP}}$.
 4: $\mathrm{INDX}$ – INTEGERInput

On entry: indicates which independent variable is to be deleted from the model.
Constraint:
$1\le {\mathbf{INDX}}\le {\mathbf{IP}}$.

On entry: the residual sum of squares for the full regression.
Constraint:
${\mathbf{RSS}}\ge 0.0$.
On exit: the residual sum of squares with the (
INDX)th variable removed. Note that the residual sum of squares will only be valid if the regression is of full rank, otherwise the residual sum of squares should be obtained using
G02DDF.
 6: $\mathrm{WK}\left(2\times {\mathbf{IP}}\right)$ – REAL (KIND=nag_wp) arrayWorkspace

 7: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. 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
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$

On entry,  ${\mathbf{IP}}<1$, 
or  ${\mathbf{LDQ}}<{\mathbf{IP}}$, 
or  ${\mathbf{INDX}}<1$, 
or  ${\mathbf{INDX}}>{\mathbf{IP}}$, 
or  ${\mathbf{RSS}}<0.0$. 
 ${\mathbf{IFAIL}}=2$

On entry,  a diagonal element of $R$ is zero. 
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=399$
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.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7 Accuracy
There will inevitably be some loss in accuracy in fitting a model by dropping terms from a more complex model rather than fitting it afresh using
G02DAF.
8 Parallelism and Performance
G02DFF 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 implementationspecific information.
None.
10 Example
A dataset consisting of
$12$ observations on four independent variables and one dependent variable is read in. The full model, including a mean term, is fitted using
G02DAF. The value of
INDX is read in and that variable dropped from the regression. The parameter estimates are calculated by
G02DDF and printed. This process is repeated until
INDX is
$0$.
10.1 Program Text
Program Text (g02dffe.f90)
10.2 Program Data
Program Data (g02dffe.d)
10.3 Program Results
Program Results (g02dffe.r)