NAG Library Routine Document
G02DCF adds or deletes an observation from a general regression model fitted by G02DAF
|SUBROUTINE G02DCF (
||UPDATE, MEAN, WEIGHT, M, ISX, Q, LDQ, IP, X, IX, Y, WT, RSS, WK, IFAIL)
||M, ISX(M), LDQ, IP, IX, IFAIL
||Q(LDQ,IP+1), X(*), Y, WT, RSS, WK(3*IP)
||UPDATE, MEAN, WEIGHT|
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
and the upper triangular matrix
produced by G02DAF
. The regression coefficients, standard errors and the variance-covariance matrix of the regression coefficients can be obtained from G02DDF
after all required changes to the dataset have been made.
decomposition on the (weighted)
matrix of independent variables. To add a new observation to a model with
parameters, the upper triangular matrix
) are augmented by the new observation on independent variables in
and dependent variable
. Givens rotations are then used to restore the upper triangular form.
and the upper part of
are updated the remainder of the
matrix is unchanged.
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
- 1: UPDATE – CHARACTER(1)Input
: indicates if an observation is to be added or deleted.
- The observation is added.
- The observation is deleted.
- 2: MEAN – CHARACTER(1)Input
: indicates if a mean has been used in the model.
- A mean term or intercept will have been included in the model by G02DAF.
- A model with no mean term or intercept will have been fitted by G02DAF.
- 3: WEIGHT – CHARACTER(1)Input
: indicates if a weight is to be used.
- The new observation is unweighted.
- The new observation is to be weighted and the weight must be supplied in WT.
- 4: M – INTEGERInput
On entry: , the total number of independent variables in the dataset.
- 5: ISX(M) – INTEGER arrayInput
On entry: if
is greater than , the value contained in is to be included as a value of , for .
elements of ISX
, exactly IP
elements of ISX
- 6: Q(LDQ,) – REAL (KIND=nag_wp) arrayInput/Output
: must be array Q
as output by G02DAF
, or a previous call to G02DCF.
: the first IP
elements of the first column of Q
the upper triangular part of columns
the remainder is unchanged.
- 7: LDQ – INTEGERInput
: the first dimension of the array Q
as declared in the (sub)program from which G02DCF is called.
- 8: IP – INTEGERInput
On entry: the number of linear terms in general linear regression model (including mean if there is one).
- 9: X() – REAL (KIND=nag_wp) arrayInput
the dimension of the array X
must be at least
: the IP
values for the dependent variables of the new observation,
. The positions will depend on the value of IX
- 10: IX – INTEGERInput
: the increment for elements of X
Two situations are common:
- The values of are to be chosen from consecutive locations in X, i.e., .
- The values of are to be chosen from a row of a two-dimensional array with first dimension LDX, i.e., .
- 11: Y – REAL (KIND=nag_wp)Input
On entry: the value of the dependent variable for the new observation, .
- 12: WT – REAL (KIND=nag_wp)Input
must contain the weight to be used with the new observation.
If , the observation is not included in the model.
is not referenced.
if , .
On entry: the value of the residual sums of squares for the original set of observations.
: the updated values of the residual sums of squares.
Note: this will only be valid if the model is of full rank.
- 14: WK() – REAL (KIND=nag_wp) arrayWorkspace
- 15: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|or|| or ,|
|or|| or ,|
|or|| or ,|
|or|| and there are not exactly nonzero values of ISX,|
|or|| and there are not exactly IP nonzero values of ISX,|
|On entry,|| and .|
matrix could not be updated. This may occur if an attempt is made to delete an observation which was not in the original dataset or to add an observation to a
matrix with a zero diagonal element. This error is also possible when removing an observation which reduces the rank of design matrix. In such cases the model should be recomputed using G02DAF
The residual sums of squares cannot be updated. This will occur if the input residual sum of squares is less than the calculated decrease in residual sum of squares when the new observation is deleted.
Higher accuracy is achieved by updating the matrix rather than the traditional methods of updating .
Care should be taken with the use of G02DCF.
||It is possible to delete observations which were not included in the original model.
||If several additions/deletions have been performed you are advised to recompute the regression using G02DAF.
||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
A dataset consisting of
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.
9.1 Program Text
Program Text (g02dcfe.f90)
9.2 Program Data
Program Data (g02dcfe.d)
9.3 Program Results
Program Results (g02dcfe.r)