# naginterfaces.library.linsys.real_​gen_​lsq_​covmat¶

naginterfaces.library.linsys.real_gen_lsq_covmat(job, sigma, a, svd, irank, sv)[source]

real_gen_lsq_covmat returns elements of the estimated variance-covariance matrix of the sample regression coefficients for the solution of a linear least squares problem.

The function can be used to find the estimated variances of the sample regression coefficients.

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

https://www.nag.com/numeric/nl/nagdoc_29.2/flhtml/f04/f04yaf.html

Parameters
jobint

Specifies which elements of are required.

The upper triangular part of is required.

The diagonal elements of are required.

The elements of column of are required.

sigmafloat

The standard error of the residual vector.

afloat, array-like, shape

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

If , must contain the upper triangular matrix of the factorization of , or of the Cholesky factorization of ; elements of the array below the diagonal need not be set.

If , must contain the first rows of the matrix , where is the rank of and is the right-hand orthogonal matrix of the singular value decomposition of .

Thus the th row must contain the th right-hand singular vector of .

svdbool

Must be if the least squares solution was obtained from a singular value decomposition of . must be if the least squares solution was obtained from either a factorization of or a Cholesky factorization of . In the latter case the rank of is assumed to be and so is applicable only to full rank problems with .

irankint

If , must specify the rank of the matrix .

If , is not referenced and the rank of is assumed to be .

svfloat, array-like, shape

If , must contain the first singular values of .

If , is not referenced.

Returns
afloat, ndarray, shape

If , is unchanged.

If , contains the upper triangle of the symmetric matrix .

If , elements of the array below the diagonal are used as workspace.

If , they are unchanged.

cjfloat, ndarray, shape

If , returns the diagonal elements of .

If , returns the th column of .

If , is not referenced.

Raises
NagValueError
(errno )

On entry, and .

Constraint: if , .

(errno )

On entry, and .

Constraint: if and , .

(errno )

On entry, , and .

Constraint: if and , .

(errno )

On entry, and .

Constraint: if , and .

(errno )

On entry, and .

Constraint: and .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, and overflow would occur in calculating an element of . The upper triangular matrix must be very nearly singular.

(errno )

On entry, and one of the first singular values is zero. Either the first singular values or must be incorrect: .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

The estimated variance-covariance matrix of the sample regression coefficients is given by

where is the normal matrix for the linear least squares regression problem

is the estimated variance of the residual vector , and is an observation matrix.

When is singular, is taken to be

where is the pseudo-inverse of ; this assumes that the minimal least squares solution of (1) has been found.

The diagonal elements of are the estimated variances of the sample regression coefficients, .

The function can be used to find either the diagonal elements of , or the elements of the th column of , or the upper triangular part of .

This function must be preceded by a function that returns either the upper triangular matrix of the factorization of or of the Cholesky factorization of , or the singular values and right singular vectors of . In particular this function can be preceded by one of the functions lapackeig.dgelss or real_gen_solve(), which return the arguments , , and in the required form. real_gen_solve() returns the argument , but when this function is used following function lapackeig.dgelss the argument should be set to . The argument of this function corresponds to the argument in functions lapackeig.dgelss and real_gen_solve().

References

Anderson, T W, 1958, An Introduction to Multivariate Statistical Analysis, Wiley

Lawson, C L and Hanson, R J, 1974, Solving Least Squares Problems, Prentice–Hall