g02dcf adds or deletes an observation from a general regression model fitted by
g02daf.
g02daf fits a general linear regression model to a dataset. You may wish to change the model by either adding or deleting an observation from the dataset.
g02dcf takes the results from
g02daf and makes the required changes to the vector
$c$ and the upper triangular matrix
$R$ produced by
g02daf. The regression coefficients, standard errors and the variancecovariance matrix of the regression coefficients can be obtained from
g02ddf after all required changes to the dataset have been made.
g02daf performs a
$QR$ decomposition on the (weighted)
$X$ matrix of independent variables. To add a new observation to a model with
$p$ parameters, the upper triangular matrix
$R$ and vector
${c}_{1}$ (the first
$p$ elements of
$c$) are augmented by the new observation on independent variables in
${x}^{\mathrm{T}}$ and dependent variable
${y}_{\text{new}}$. Givens rotations are then used to restore the upper triangular form.
Note: only
$R$ and the upper part of
$c$ are updated the remainder of the
$Q$ matrix is unchanged.
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25

1:
$\mathbf{update}$ – Character(1)
Input

On entry: indicates if an observation is to be added or deleted.
 ${\mathbf{update}}=\text{'A'}$
 The observation is added.
 ${\mathbf{update}}=\text{'D'}$
 The observation is deleted.
Constraint:
${\mathbf{update}}=\text{'A'}$ or $\text{'D'}$.

2:
$\mathbf{mean}$ – Character(1)
Input

On entry: indicates if a mean has been used in the model.
 ${\mathbf{mean}}=\text{'M'}$
 A mean term or intercept will have been included in the model by g02daf.
 ${\mathbf{mean}}=\text{'Z'}$
 A model with no mean term or intercept will have been fitted by g02daf.
Constraint:
${\mathbf{mean}}=\text{'M'}$ or $\text{'Z'}$.

3:
$\mathbf{weight}$ – Character(1)
Input

On entry: indicates if a weight is to be used.
 ${\mathbf{weight}}=\text{'U'}$
 The new observation is unweighted.
 ${\mathbf{weight}}=\text{'W'}$
 The new observation is to be weighted and the weight must be supplied in wt.
Constraint:
${\mathbf{weight}}=\text{'U'}$ or $\text{'W'}$.

4:
$\mathbf{m}$ – Integer
Input

On entry: $m$, the total number of independent variables in the dataset.
Constraint:
${\mathbf{m}}\ge 1$.

5:
$\mathbf{isx}\left({\mathbf{m}}\right)$ – Integer array
Input

On entry: if
${\mathbf{isx}}\left(\mathit{j}\right)$ is greater than $0$, the value contained in ${\mathbf{x}}\left(\left(\mathit{j}1\right)\times {\mathbf{ix}}+1\right)$ is to be included as a value of ${x}^{\mathrm{T}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{m}}$.
Constraint:
if
${\mathbf{mean}}=\text{'M'}$, exactly
${\mathbf{ip}}1$ elements of
isx must be
$\text{}>0$ and if
${\mathbf{mean}}=\text{'Z'}$, exactly
ip elements of
isx must be
$\text{}>0$.

6:
$\mathbf{q}\left({\mathbf{ldq}},{\mathbf{ip}}+1\right)$ – Real (Kind=nag_wp) array
Input/Output

On entry: must be array
q as output by
g02daf,
g02def,
g02dff or
g02eef, or a previous call to
g02dcf.
On exit: the first
ip elements of the first column of
q will contain
${c}_{1}^{*}$ the upper triangular part of columns
$2$ to
${\mathbf{ip}}+1$ will contain
${R}^{*}$ the remainder is unchanged.

7:
$\mathbf{ldq}$ – Integer
Input

On entry: the first dimension of the array
q as declared in the (sub)program from which
g02dcf is called.
Constraint:
${\mathbf{ldq}}\ge {\mathbf{ip}}$.

8:
$\mathbf{ip}$ – Integer
Input

On entry: the number of linear terms in general linear regression model (including mean if there is one).
Constraint:
${\mathbf{ip}}\ge 1$.

9:
$\mathbf{x}\left(*\right)$ – Real (Kind=nag_wp) array
Input

Note: the dimension of the array
x
must be at least
$\left({\mathbf{m}}1\right)\times {\mathbf{ix}}+1$.
On entry: the
ip values for the dependent variables of the new observation,
${x}^{\mathrm{T}}$. The positions will depend on the value of
ix.

10:
$\mathbf{ix}$ – Integer
Input

On entry: the increment for elements of
x.
Two situations are common:
 ${\mathbf{ix}}=1$
 The values of $x$ are to be chosen from consecutive locations in x, i.e., ${\mathbf{x}}\left(1\right),{\mathbf{x}}\left(2\right),\dots ,{\mathbf{x}}\left({\mathbf{m}}\right)$.
 ${\mathbf{ix}}={\mathbf{ldx}}$
 The values of $x$ are to be chosen from a row of a twodimensional array with first dimension ldx, i.e., ${\mathbf{x}}\left(1\right),{\mathbf{x}}\left({\mathbf{ldx}}+1\right),\dots ,{\mathbf{x}}\left(\left({\mathbf{m}}1\right){\mathbf{ldx}}+1\right)$.
Constraint:
${\mathbf{ix}}\ge 1$.

11:
$\mathbf{y}$ – Real (Kind=nag_wp)
Input

On entry: the value of the dependent variable for the new observation, ${y}_{\text{new}}$.

12:
$\mathbf{wt}$ – Real (Kind=nag_wp)
Input

On entry: if
${\mathbf{weight}}=\text{'W'}$,
wt must contain the weight to be used with the new observation.
If ${\mathbf{wt}}=0.0$, the observation is not included in the model.
If
${\mathbf{weight}}=\text{'U'}$,
wt is not referenced.
Constraint:
if ${\mathbf{weight}}=\text{'W'}$, ${\mathbf{wt}}\ge 0.0$.

On entry: the value of the residual sums of squares for the original set of observations.
Constraint:
${\mathbf{rss}}\ge 0.0$.
On exit: the updated values of the residual sums of squares.
Note: this will only be valid if the model is of full rank.

14:
$\mathbf{wk}\left(3\times {\mathbf{ip}}\right)$ – Real (Kind=nag_wp) array
Workspace


15:
$\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).
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
 ${\mathbf{ifail}}=1$

On entry, $\u2329\mathit{\text{value}}\u232a$ elements of ${\mathbf{isx}}>0$ instead of ${\mathbf{ip}}=\u2329\mathit{\text{value}}\u232a$.
On entry, $\u2329\mathit{\text{value}}\u232a$ elements of ${\mathbf{isx}}>0$ instead of ${\mathbf{ip}}1$ (for mean) $\text{}=\u2329\mathit{\text{value}}\u232a$.
On entry, ${\mathbf{ip}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ip}}\ge 1$.
On entry, ${\mathbf{ix}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ix}}\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{mean}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{mean}}=\text{'M'}$ or $\text{'Z'}$.
On entry, ${\mathbf{rss}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{rss}}\ge 0.0$.
On entry, ${\mathbf{update}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{update}}=\text{'A'}$ or $\text{'D'}$.
On entry, ${\mathbf{weight}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{weight}}=\text{'U'}$ or $\text{'W'}$.
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.
Care should be taken with the use of
g02dcf.

(a)It is possible to delete observations which were not included in the original model.

(b)If several additions/deletions have been performed you are advised to recompute the regression using g02daf.

(c)Adding or deleting observations can alter the rank of the model. Such changes will only be detected when a call to g02ddf has been made. g02ddf should also be used to compute the new residual sum of squares when the model is not of full rank.
g02dcf may also be used after
g02def,
g02dff and
g02eef.
A dataset consisting of
$12$ observations with four independent variables is read in and a general linear regression model fitted by
g02daf and parameter estimates printed. The last observation is then dropped and the parameter estimates recalculated, using
g02ddf, and printed. Finally a new observation is added and new parameter estimates computed and printed.