NAG Library Routine Document
F04YAF
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
SUBROUTINE F04YAF ( |
JOB, P, SIGMA, A, LDA, SVD, IRANK, SV, CJ, WORK, IFAIL) |
INTEGER |
JOB, P, LDA, IRANK, IFAIL |
REAL (KIND=nag_wp) |
SIGMA, A(LDA,P), SV(P), CJ(P), WORK(P) |
LOGICAL |
SVD |
|
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 (DGELSS), which return the parameters
IRANK,
SIGMA,
A and
SV in the required form.
F04JGF returns the parameter
SVD, but when this routine is used following routine
F08KAF (DGELSS) the parameter
SVD should be set to .TRUE.. The parameter
P of this routine corresponds to the parameter
N in routines
F04JGF and
F08KAF (DGELSS).
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 Parameters
- 1: JOB – INTEGERInput
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: P – INTEGERInput
On entry: , the order of the variance-covariance matrix .
Constraint:
.
- 3: SIGMA – REAL (KIND=nag_wp)Input
On entry:
, the standard error of the residual vector given by
where
is the rank of
.
Constraint:
.
- 4: A(LDA,P) – 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: LDA – 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: SVD – 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: IRANK – 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: SV(P) – REAL (KIND=nag_wp) arrayInput
On entry: if
,
SV must contain the first
IRANK singular values of
.
If
,
SV is not referenced.
- 9: CJ(P) – REAL (KIND=nag_wp) arrayOutput
On exit: if
,
CJ returns the diagonal elements of
.
If
,
CJ returns the
th column of
.
If
,
CJ is not referenced.
- 10: WORK(P) – REAL (KIND=nag_wp) arrayWorkspace
If
,
WORK is not referenced.
- 11: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction 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 parameter, 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, | , |
or | , |
or | , |
or | , |
or | and ( or ) or ( and ) or ( and )), |
or | and . |
On entry, and .
On entry, and overflow would occur in computing 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.
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.
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.
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 .
9 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.
9.1 Program Text
Program Text (f04yafe.f90)
9.2 Program Data
Program Data (f04yafe.d)
9.3 Program Results
Program Results (f04yafe.r)