naginterfaces.library.correg.linregm_obs_edit¶
- naginterfaces.library.correg.linregm_obs_edit(update, isx, q, x, ix, y, rss, mean='M', wt=None)[source]¶
linregm_obs_edit
adds or deletes an observation from a general regression model fitted bylinregm_fit()
.For full information please refer to the NAG Library document for g02dc
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02dcf.html
- Parameters
- updatestr, length 1
Indicates if an observation is to be added or deleted.
The observation is added.
The observation is deleted.
- isxint, array-like, shape
If is greater than , the value contained in is to be included as a value of , for .
- qfloat, array-like, shape
Must be array as output by
linregm_fit()
,linregm_var_add()
,linregm_var_del()
orlinregm_fit_onestep()
, or a previous call tolinregm_obs_edit
.- xfloat, array-like, shape
The values for the dependent variables of the new observation, . The positions will depend on the value of .
- ixint
The increment for elements of . Two situations are common:
The values of are to be chosen from consecutive locations in , i.e., .
The values of are to be chosen from a row of a two-dimensional array with first dimension , i.e., .
- yfloat
The value of the dependent variable for the new observation, .
- rssfloat
The value of the residual sums of squares for the original set of observations.
- meanstr, length 1, optional
Indicates if a mean has been used in the model.
A mean term or intercept will have been included in the model by
linregm_fit()
.A model with no mean term or intercept will have been fitted by
linregm_fit()
.- wtNone or float, optional
If provided, must contain the weight to be used with the new observation.
If is None, the observation is not included in the model.
- Returns
- qfloat, ndarray, shape
The first elements of the first column of will contain the upper triangular part of columns to will contain the remainder is unchanged.
- rssfloat
The updated values of the residual sums of squares.
Note: this will only be valid if the model is of full rank.
- Raises
- NagValueError
- (errno )
On entry, elements of instead of (for mean) .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, elements of instead of .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
The matrix could not be updated.
- (errno )
The residual sums of squares cannot be updated.
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
linregm_fit()
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.linregm_obs_edit
takes the results fromlinregm_fit()
and makes the required changes to the vector and the upper triangular matrix produced bylinregm_fit()
. The regression coefficients, standard errors and the variance-covariance matrix of the regression coefficients can be obtained fromlinregm_update()
after all required changes to the dataset have been made.linregm_fit()
performs a decomposition on the (weighted) matrix of independent variables. To add a new observation to a model with parameters, 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.Note: only and the upper part of are updated the remainder of the 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