naginterfaces.library.correg.linregm_​fit_​newvar

naginterfaces.library.correg.linregm_fit_newvar(rss, irank, cov, q, svd, p, y, wk, wt=None)[source]

linregm_fit_newvar calculates the estimates of the parameters of a general linear regression model for a new dependent variable after a call to linregm_fit().

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

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g02/g02dgf.html

Parameters
rssfloat

The residual sum of squares for the original dependent variable.

irankint

The rank of the independent variables, as given by linregm_fit().

covfloat, array-like, shape

The covariance matrix of the parameter estimates as given by linregm_fit().

qfloat, array-like, shape

The results of the decomposition as returned by linregm_fit().

svdbool

Indicates if a singular value decomposition was used by linregm_fit().

A singular value decomposition was used by linregm_fit().

A singular value decomposition was not used by linregm_fit().

pfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

Details of the decomposition and SVD, if used, as returned in array by linregm_fit().

If , only the first elements of are used; these contain the zeta values for the decomposition (see lapackeig.dgeqrf for details).

If , the first elements of contain the zeta values for the decomposition (see lapackeig.dgeqrf for details) and the next elements of contain details of the singular value decomposition.

yfloat, array-like, shape

The new dependent variable, .

wkfloat, array-like, shape

If , must be unaltered from the previous call to linregm_fit() or linregm_fit_newvar.

If , is used as workspace.

wtNone or float, array-like, shape , optional

If provided must contain the weights to be used with the model.

If , the th observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights.

If is not provided the effective number of observations is .

Returns
rssfloat

The residual sum of squares for the new dependent variable.

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 .

qfloat, ndarray, shape

The first column of contains the new values of , the remainder of will be unchanged.

bfloat, ndarray, shape

The least squares estimates of the parameters of the regression model, .

sefloat, ndarray, shape

The standard error of the estimates of the parameters.

resfloat, ndarray, shape

The residuals for the new regression model.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: if , .

(errno )

On entry, and .

Constraint: if , .

(errno )

On entry, .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: , for .

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_newvar uses the results given by linregm_fit() to fit the same set of independent variables to a new dependent variable.

linregm_fit() computes a decomposition of the matrix of independent variables and also, if the model is not of full rank, a singular value decomposition (SVD). These results can be used to compute estimates of the parameters for a general linear model with a new dependent variable. The decomposition leads to the formation of an upper triangular matrix and an orthogonal matrix . In addition the vector (or ) is computed. For a new dependent variable, , linregm_fit_newvar computes a new value of or .

If is of full rank, then the least squares parameter estimates, , are the solution to

where is the first elements of .

If is not of full rank, then linregm_fit() will have computed an 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 by linregm_fit() in the form of the matrix :

The matrix is made available through the workspace of linregm_fit().

In addition to parameter estimates, the new residuals are computed and the variance-covariance matrix of the parameter estimates are found by scaling the variance-covariance matrix for the original regression.

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