NAG FL Interface
f04yaf (real_gen_lsq_covmat)
1
Purpose
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.
2
Specification
Fortran Interface
Subroutine f04yaf ( |
job, p, sigma, a, lda, svd, irank, sv, cj, work, ifail) |
Integer, Intent (In) |
:: |
job, p, lda, irank |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
sigma, sv(p) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
a(lda,p) |
Real (Kind=nag_wp), Intent (Out) |
:: |
cj(p), work(p) |
Logical, Intent (In) |
:: |
svd |
|
C Header Interface
#include <nag.h>
void |
f04yaf_ (const Integer *job, const Integer *p, const double *sigma, double a[], const Integer *lda, const logical *svd, const Integer *irank, const double sv[], double cj[], double work[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
f04yaf_ (const Integer &job, const Integer &p, const double &sigma, double a[], const Integer &lda, const logical &svd, const Integer &irank, const double sv[], double cj[], double work[], Integer &ifail) |
}
|
The routine may be called by the names f04yaf or nagf_linsys_real_gen_lsq_covmat.
3
Description
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
by
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
f04jgf or
f08kaf, 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
f04jgf and
f08kaf.
4
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
5
Arguments
-
1:
– Integer
Input
-
On entry: specifies which elements of
are required.
- The upper triangular part of is required.
- The diagonal elements of are required.
- The elements of column job of are required.
Constraint:
.
-
2:
– Integer
Input
-
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) array
Input/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:
– Integer
Input
-
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:
– Logical
Input
-
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:
– Integer
Input
-
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) array
Input
-
On entry: if
,
sv must contain the first
irank singular values of
.
If
,
sv is not referenced.
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit: if
,
cj returns the diagonal elements of
.
If
,
cj returns the
th column of
.
If
,
cj is not referenced.
-
10:
– Real (Kind=nag_wp) array
Workspace
-
If
,
work is not referenced.
-
11:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value 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).
6
Error 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.
7
Accuracy
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.
8
Parallelism 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.
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 .
10
Example
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.
10.1
Program Text
10.2
Program Data
10.3
Program Results