NAG FL Interface
g02dff (linregm_var_del)
1
Purpose
g02dff deletes an independent variable from a general linear regression model.
2
Specification
Fortran Interface
Integer, Intent (In) 
:: 
ip, ldq, indx 
Integer, Intent (Inout) 
:: 
ifail 
Real (Kind=nag_wp), Intent (Inout) 
:: 
q(ldq,ip+1), rss 
Real (Kind=nag_wp), Intent (Out) 
:: 
wk(2*ip) 

C Header Interface
#include <nag.h>
void 
g02dff_ (const Integer *ip, double q[], const Integer *ldq, const Integer *indx, double *rss, double wk[], Integer *ifail) 

C++ Header Interface
#include <nag.h> extern "C" {
void 
g02dff_ (const Integer &ip, double q[], const Integer &ldq, const Integer &indx, double &rss, double wk[], Integer &ifail) 
}

The routine may be called by the names g02dff or nagf_correg_linregm_var_del.
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:
$\mathbf{ip}$ – Integer
Input

On entry: $p$, the number of independent variables already in the model.
Constraint:
${\mathbf{ip}}\ge 1$.

2:
$\mathbf{q}\left({\mathbf{ldq}},{\mathbf{ip}}+1\right)$ – Real (Kind=nag_wp) array
Input/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:
$\mathbf{ldq}$ – Integer
Input

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:
$\mathbf{indx}$ – Integer
Input

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:
$\mathbf{wk}\left(2\times {\mathbf{ip}}\right)$ – Real (Kind=nag_wp) array
Workspace


7:
$\mathbf{ifail}$ – Integer
Input/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 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
$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{indx}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{indx}}\ge 1$ and ${\mathbf{indx}}\le {\mathbf{ip}}$.
On entry, ${\mathbf{ip}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ip}}\ge 1$.
On entry, ${\mathbf{ldq}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{ip}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ldq}}\ge {\mathbf{ip}}$.
On entry, ${\mathbf{rss}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{rss}}\ge 0.0$.
 ${\mathbf{ifail}}=2$

On entry, ${\mathbf{q}}\left(\u2329\mathit{\text{value}}\u232a,\u2329\mathit{\text{value}}\u232a\right)=0.0$.
 ${\mathbf{ifail}}=99$
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.
 ${\mathbf{ifail}}=399$
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.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface 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
10.2
Program Data
10.3
Program Results