NAG Library Routine Document
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.
|SUBROUTINE F04YAF (
||JOB, P, SIGMA, A, LDA, SVD, IRANK, SV, CJ, WORK, IFAIL)
||JOB, P, LDA, IRANK, IFAIL
||SIGMA, A(LDA,P), SV(P), CJ(P), WORK(P)
The estimated variance-covariance matrix
of the sample regression coefficients is given by
is the normal matrix for the linear least squares regression problem
is the estimated variance of the residual vector
is taken to be
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
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
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)
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
- 1: JOB – INTEGERInput
: specifies which elements of
- The upper triangular part of is required.
- The diagonal elements of are required.
- The elements of column JOB of are required.
- 2: P – INTEGERInput
On entry: , the order of the variance-covariance matrix .
- 3: SIGMA – REAL (KIND=nag_wp)Input
, the standard error of the residual vector given by
is the rank of
- 4: A(LDA,P) – REAL (KIND=nag_wp) arrayInput/Output
must contain the upper triangular matrix
, 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 .
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
: the first dimension of the array A
as declared in the (sub)program from which F04YAF is called.
- if or , ;
- if and , .
- 6: SVD – LOGICALInput
: must be .TRUE. if the least squares solution was obtained from a singular value decomposition of
must be .FALSE. if the least squares solution was obtained from either a
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
must specify the rank
of the matrix
is not referenced and the rank of
is assumed to be
- 8: SV(P) – REAL (KIND=nag_wp) arrayInput
must contain the first IRANK
singular values of
is not referenced.
- 9: CJ(P) – REAL (KIND=nag_wp) arrayOutput
returns the diagonal elements of
th column of
is not referenced.
- 10: WORK(P) – REAL (KIND=nag_wp) arrayWorkspace
is not referenced.
- 11: IFAIL – INTEGERInput/Output
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.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|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.
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.
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 .
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)