f04yaf returns elements of the estimated variance-covariance matrix of the sample regression coefficients for the solution of a linear least squares problem.
The routine can be used to find the estimated variances of the sample regression coefficients.
The routine may be called by the names f04yaf or nagf_linsys_real_gen_lsq_covmat.
3Description
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
(1)
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 routine 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 routine must be preceded by a routine 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 routine can be preceded by one of the routines f04jgforf08kaf, which return the arguments irank, sigma, a and sv in the required form. f04jgf returns the argument svd, but when this routine is used following routine f08kaf the argument svd should be set to .TRUE.. The argument p of this routine corresponds to the argument n in routines f04jgfandf08kaf.
4References
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
5Arguments
1: – IntegerInput
On entry: specifies which elements of are required.
On entry: , the order of the variance-covariance matrix .
Constraint:
.
3: – Real (Kind=nag_wp)Input
On entry: , the standard error of the residual vector given by
where is the rank of .
Constraint:
.
4: – Real (Kind=nag_wp) arrayInput/Output
On entry: if , a 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 .
On exit: if , is unchanged.
If , a contains the upper triangle of the symmetric matrix .
If , elements of the array below the diagonal are used as workspace.
If , they are unchanged.
5: – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f04yaf is called.
Constraints:
if or , ;
if and , .
6: – LogicalInput
On entry: must be .TRUE. if the least squares solution was obtained from a singular value decomposition of . svd must be .FALSE. 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 .
7: – IntegerInput
On entry: if , irank must specify the rank of the matrix .
If , irank is not referenced and the rank of is assumed to be .
Constraint:
.
8: – Real (Kind=nag_wp) arrayInput
On entry: if , sv must contain the first irank singular values of .
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, and .
Constraint: if , and .
On entry, , and .
Constraint: if and , .
On entry, and .
Constraint: and .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: if and , .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: if , .
On entry, and overflow would occur in calculating an element of . The upper triangular matrix must be very nearly singular.
On entry, and one of the first irank singular values is zero. Either the first irank singular values or irank must be incorrect: .
Overflow
If overflow occurs then either an element of is very large, or more likely, either the rank, or the upper triangular matrix, or the singular values or vectors have been incorrectly supplied.
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The computed elements of will be the exact covariances of a closely neighbouring least squares problem, so long as a numerically stable method has been used in the solution of the least squares problem.
8Parallelism and Performance
f04yaf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
When the time taken by f04yaf is approximately proportional to , where is the rank of . When and , the time taken by the routine is approximately proportional to , otherwise the time taken is approximately proportional to .
10Example
This example finds the estimated variances of the sample regression coefficients (the diagonal elements of ) for the linear least squares problem
following a solution obtained by f04jgf. See the routine document for f04jgf for further information.