g02dc adds or deletes an observation from a general regression model fitted by g02da.

Syntax

C#
public static void g02dc(
	string update,
	string mean,
	string weight,
	int m,
	int[] isx,
	double[,] q,
	int ip,
	double[] x,
	int ix,
	double y,
	double wt,
	ref double rss,
	out int ifail
)
Visual Basic
Public Shared Sub g02dc ( _
	update As String, _
	mean As String, _
	weight As String, _
	m As Integer, _
	isx As Integer(), _
	q As Double(,), _
	ip As Integer, _
	x As Double(), _
	ix As Integer, _
	y As Double, _
	wt As Double, _
	ByRef rss As Double, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g02dc(
	String^ update, 
	String^ mean, 
	String^ weight, 
	int m, 
	array<int>^ isx, 
	array<double,2>^ q, 
	int ip, 
	array<double>^ x, 
	int ix, 
	double y, 
	double wt, 
	double% rss, 
	[OutAttribute] int% ifail
)
F#
static member g02dc : 
        update : string * 
        mean : string * 
        weight : string * 
        m : int * 
        isx : int[] * 
        q : float[,] * 
        ip : int * 
        x : float[] * 
        ix : int * 
        y : float * 
        wt : float * 
        rss : float byref * 
        ifail : int byref -> unit 

Parameters

update
Type: System..::..String
On entry: indicates if an observation is to be added or deleted.
update="A"
The observation is added.
update="D"
The observation is deleted.
Constraint: update="A" or "D".
mean
Type: System..::..String
On entry: indicates if a mean has been used in the model.
mean="M"
A mean term or intercept will have been included in the model by g02da.
mean="Z"
A model with no mean term or intercept will have been fitted by g02da.
Constraint: mean="M" or "Z".
weight
Type: System..::..String
On entry: indicates if a weight is to be used.
weight="U"
The new observation is unweighted.
weight="W"
The new observation is to be weighted and the weight must be supplied in wt.
Constraint: weight="U" or "W".
m
Type: System..::..Int32
On entry: m, the total number of independent variables in the dataset.
Constraint: m1.
isx
Type: array<System..::..Int32>[]()[][]
An array of size [m]
On entry: if isx[j-1] is greater than 0, the value contained in x[j-1×ix] is to be included as a value of xT, for j=1,2,,m.
Constraint: if mean="M", exactly ip-1 elements of isx must be >0 and if mean="Z", exactly ip elements of isx must be >0.
q
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, ip+1]
Note: dim1 must satisfy the constraint: dim1ip
On entry: must be array q as output by g02da g02de g02df (G02EEF not in this release), or a previous call to g02dc.
On exit: the first ip elements of the first column of q will contain c1* the upper triangular part of columns 2 to ip+1 will contain R* the remainder is unchanged.
ip
Type: System..::..Int32
On entry: the number of linear terms in general linear regression model (including mean if there is one).
Constraint: ip1.
x
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: the dimension of the array x must be at least m-1×ix+1.
On entry: the ip values for the dependent variables of the new observation, xT. The positions will depend on the value of ix.
ix
Type: System..::..Int32
On entry: the increment for elements of x.
Constraint: ix1.
y
Type: System..::..Double
On entry: the value of the dependent variable for the new observation, ynew.
wt
Type: System..::..Double
On entry: if weight="W" , wt must contain the weight to be used with the new observation.
If wt=0.0, the observation is not included in the model.
If weight="U", wt is not referenced.
Constraint: if wt0.0, weight="W".
rss
Type: System..::..Double%
On entry: the value of the residual sums of squares for the original set of observations.
Constraint: rss0.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.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

g02da 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. g02dc takes the results from g02da and makes the required changes to the vector c and the upper triangular matrix R produced by g02da. The regression coefficients, standard errors and the variance-covariance matrix of the regression coefficients can be obtained from g02dd after all required changes to the dataset have been made.
g02da 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 c1 (the first p elements of c) are augmented by the new observation on independent variables in xT and dependent variable ynew. Givens rotations are then used to restore the upper triangular form.
R:c1x:ynewR*:c1*0:ynew*.
Note:  only R and the upper part of c are updated the remainder of the Q matrix is unchanged.

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

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDQ) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,ip<1,
orm<1,
orix<1,
orrss<0.0,
orupdate"A" or "D",
ormean"M" or "Z",
orweight"U" or "W",
ormean="M" and there are not exactly ip-1 nonzero values of isx,
ormean="Z" and there are not exactly ip nonzero values of isx,
ifail=2
On entry,weight="W" and wt<0.0.
ifail=3
The R 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 R 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 g02da.
ifail=4
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.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Higher accuracy is achieved by updating the R matrix rather than the traditional methods of updating XX.

Parallelism and Performance

None.

Further Comments

Care should be taken with the use of g02dc.
(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 g02da.
(c) Adding or deleting observations can alter the rank of the model. Such changes will only be detected when a call to g02dd has been made. g02dd should also be used to compute the new residual sum of squares when the model is not of full rank.
g02dc may also be used after g02de g02df (G02EEF not in this release).

Example

See Also