naginterfaces.library.correg.linregm_​update

naginterfaces.library.correg.linregm_update(q, rss, p, tol=1e-06)[source]

linregm_update calculates the regression parameters for a general linear regression model. It is intended to be called after linregm_obs_edit(), linregm_var_add() or linregm_var_del().

For full information please refer to the NAG Library document for g02dd

https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/g02/g02ddf.html

Parameters
qfloat, array-like, shape

Note: the required extent for this argument in dimension 1 is determined as follows: if : ; otherwise: .

Must be the array as output by linregm_obs_edit(), linregm_var_add(), linregm_var_del() or linregm_fit_onestep(). If on entry then all elements of are needed. This is provided by functions linregm_var_add(), linregm_var_del() or linregm_fit_onestep().

rssfloat

Either the residual sum of squares or a value less than or equal to to indicate that the residual sum of squares is to be calculated by the function.

pfloat, array-like, shape

Must be array as output by linregm_fit(), linregm_var_add() or linregm_fit_onestep(), or a previous call to linregm_update.

tolfloat, optional

The value of is used to decide if the independent variables are of full rank and, if not, what is the rank of the independent variables. The smaller the value of the stricter the criterion for selecting the singular value decomposition. If , the singular value decomposition will never be used, this may cause run time errors or inaccuracies if the independent variables are not of full rank.

Returns
rssfloat

If on entry, then on exit will contain the residual sum of squares as calculated by linregm_update.

If was positive on entry, it will be unchanged.

idfint

The degrees of freedom associated with the residual sum of squares.

bfloat, ndarray, shape

The estimates of the parameters, .

sefloat, ndarray, shape

The standard errors of the parameters given in .

covfloat, ndarray, shape

The upper triangular part of the variance-covariance matrix of the parameter estimates given in . They are stored packed by column, i.e., the covariance between the parameter estimate given in and the parameter estimate given in , , is stored in .

svdbool

If a singular value decomposition has been performed, , otherwise .

irankint

The rank of the independent variables.

If , .

If , is an estimate of the rank of the independent variables.

is calculated as the number of singular values greater than (largest singular value).

It is possible for the SVD to be carried out but to be returned as .

pfloat, ndarray, shape

Contains details of the singular value decomposition if used.

If , is not referenced.

If , the first elements of are unchanged, the next values contain the singular values.

The following values contain the matrix stored by columns.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: if , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

The degrees of freedom for error are less than or equal to . In this case the estimates of are returned but not the standard errors or covariances.

(errno )

SVD solution failed to converge.

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.

A general linear regression model fitted by linregm_fit() may be adjusted by adding or deleting an observation using linregm_obs_edit(), adding a new independent variable using linregm_var_add() or deleting an existing independent variable using linregm_var_del(). Alternatively a model may be constructed by a forward selection procedure using linregm_fit_onestep(). These functions compute the vector and the upper triangular matrix . linregm_update takes these basic results and computes the regression coefficients, , their standard errors and their variance-covariance matrix.

If is of full rank, then is the solution to

where is the first elements of .

If is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of ,

where is a diagonal matrix with nonzero diagonal elements, being the rank of , and and are orthogonal matrices. This gives the solution

being the first columns of , i.e., , and being the first columns of .

Details of the SVD are made available in the form of the matrix :

This will be only one of the possible solutions. Other estimates may be obtained by applying constraints to the parameters. These solutions can be obtained by calling linregm_constrain() after calling linregm_update. Only certain linear combinations of the parameters will have unique estimates; these are known as estimable functions. These can be estimated using linregm_estfunc().

The residual sum of squares required to calculate the standard errors and the variance-covariance matrix can either be input or can be calculated if additional information on for the whole sample is provided.

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

Searle, S R, 1971, Linear Models, Wiley