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: – 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: – INTEGERInput
-
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
.
If
,
SV is not referenced.
- 9: – 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: – REAL (KIND=nag_wp) arrayWorkspace
-
If
,
WORK is not referenced.
- 11: – 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.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction 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 is not threaded by NAG in any implementation.
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
Program Text (f04yafe.f90)
10.2 Program Data
Program Data (f04yafe.d)
10.3 Program Results
Program Results (f04yafe.r)