nag_regsn_mult_linear_addrem_obs (g02dcc) adds or deletes an observation from a general regression model fitted by
nag_regsn_mult_linear (g02dac).
nag_regsn_mult_linear (g02dac) 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. nag_regsn_mult_linear_addrem_obs (g02dcc) takes the results from
nag_regsn_mult_linear (g02dac) and makes the required changes to the vector
and the upper triangular matrix
produced by
nag_regsn_mult_linear (g02dac). The regression coefficients, standard errors and the variance-covariance matrix of the regression coefficients can be obtained from
nag_regsn_mult_linear_upd_model (g02ddc) after all required changes to the dataset have been made.
nag_regsn_mult_linear (g02dac) performs a
decomposition on the (weighted)
matrix of independent variables. To add a new observation to a model with
arguments the upper triangular matrix
and vector
, the first
elements of
, are augmented by the new observation on independent variables in
and dependent variable
. Givens rotations are then used to restore the upper triangular form.
To delete an observation Givens rotations are applied to give:
Note: only the
and upper part of the
are updated, the remainder of the
matrix is unchanged.
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
- 1:
update – Nag_UpdateObservInput
On entry: indicates if an observation is to be added or deleted.
- The observation is added.
- The observation is deleted.
Constraint:
or .
- 2:
mean – Nag_IncludeMeanInput
On entry: indicates if a mean has been used in the model.
- A mean term or intercept will have been included in the model by nag_regsn_mult_linear (g02dac).
- A model with no mean term or intercept will have been fitted by nag_regsn_mult_linear (g02dac).
Constraint:
or .
- 3:
m – IntegerInput
On entry: the total number of independent variables in the dataset.
Constraint:
.
- 4:
sx[m] – const IntegerInput
-
On entry: if is greater than 0, then the value contained in is to be included as a value of , an observation on an independent variable, for .
Constraint:
if
, then exactly
elements of
sx must be
and if
, then exactly
ip elements of
sx must be
.
- 5:
q[] – doubleInput/Output
-
Note: the th element of the matrix is stored in .
On exit: the first
ip elements of the first column of
q will contain
, the upper triangular part of columns 2 to
will contain
, the remainder is unchanged.
- 6:
tdq – IntegerInput
-
On entry: the stride separating matrix column elements in the array
q.
Constraint:
.
- 7:
ip – IntegerInput
On entry: the number of linear terms in general linear regression model (including mean if there is one).
Constraint:
.
- 8:
x[] – const doubleInput
-
On entry: the
ip values for the dependent variables of the observation to be added or deleted,
. The positions of the values
x extracted depends on
ix and
tdx.
- 9:
nr – IntegerInput
On entry: the number of rows of the notional two-dimensional array
x.
Constraint:
.
- 10:
tdx – IntegerInput
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
- 11:
ix – IntegerInput
-
On entry: the row of the notional two-dimensional array
x that contains the values for the dependent variables of the observation to be added or deleted.
Constraint:
.
- 12:
y – doubleInput
-
On entry: the value of the dependent variable for the observation to be added or deleted, .
- 13:
wt[] – const doubleInput
-
On entry: if the new observation is to be weighted, then
wt must contain the weight to be used with the new observation. If
, then the observation is not included in the model. If the new observation is to be unweighted, then
wt must be supplied as
NULL.
Constraint:
if the new observation is to be weighted .
-
On entry: the value of the residual sums of squares for the original set of observations.
Constraint:
.
On exit: the updated values of the residual sums of squares.
Note: this will only be valid if the model is of full rank.
- 15:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_BAD_PARAM
-
On entry,
mean had an illegal value.
On entry,
update had an illegal value.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_IP_INCOMP_WITH_SX
-
On entry, for
, number of nonzero values of
sx must be equal to
: number of nonzero values of
,
.
On entry, for
, number of nonzero values of
sx must be equal to
ip: number of nonzero values of
,
.
- NE_MAT_NOT_UPD
-
The matrix could not be updated: to, either, delete nonexistent observation, or, add an observation to matrix with zero diagonal element.
- NE_REAL_ARG_LT
-
On entry, .
Constraint: .
On entry,
Constraint: .
-
The
rss could not be updated because the input
rss was less than the calculated decrease in
rss when the new observation was deleted.
Not applicable.
Care should be taken with the use of this function.
A dataset consisting of 12 observations with four independent variables is read in and a general linear regression model fitted by
nag_regsn_mult_linear (g02dac) and parameter estimates printed. The last observation is then dropped and the parameter estimates recalculated, using
nag_regsn_mult_linear_upd_model (g02ddc), and printed.