NAG Library Routine Document
G02DGF
1 Purpose
G02DGF calculates the estimates of the parameters of a general linear regression model for a new dependent variable after a call to
G02DAF.
2 Specification
SUBROUTINE G02DGF ( |
WEIGHT, N, WT, RSS, IP, IRANK, COV, Q, LDQ, SVD, P, Y, B, SE, RES, WK, IFAIL) |
INTEGER |
N, IP, IRANK, LDQ, IFAIL |
REAL (KIND=nag_wp) |
WT(*), RSS, COV(IP*(IP+1)/2), Q(LDQ,IP+1), P(*), Y(N), B(IP), SE(IP), RES(N), WK(5*(IP-1)+IP*IP) |
LOGICAL |
SVD |
CHARACTER(1) |
WEIGHT |
|
3 Description
G02DGF uses the results given by
G02DAF to fit the same set of independent variables to a new dependent variable.
G02DAF computes a
decomposition of the matrix of
independent variables and also, if the model is not of full rank, a singular value decomposition (SVD). These results can be used to compute estimates of the parameters for a general linear model with a new dependent variable. The
decomposition leads to the formation of an upper triangular
by
matrix
and an
by
orthogonal matrix
. In addition the vector
(or
) is computed. For a new dependent variable,
, G02DGF computes a new value of
or
.
If
is of full rank, then the least squares parameter estimates,
, are the solution to
where
is the first
elements of
.
If
is not of full rank, then
G02DAF will have computed an SVD of
,
where
is a
by
diagonal matrix with nonzero diagonal elements,
being the rank of
, and
and
are
by
orthogonal matrices. This gives the solution
being the first
columns of
, i.e.,
, and
being the first
columns of
. Details of the SVD are made available by
G02DAF in the form of the matrix
:
The matrix
is made available through the workspace of
G02DAF.
In addition to parameter estimates, the new residuals are computed and the variance-covariance matrix of the parameter estimates are found by scaling the variance-covariance matrix for the original regression.
4 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
Searle S R (1971) Linear Models Wiley
5 Parameters
- 1: WEIGHT – CHARACTER(1)Input
On entry: indicates if weights are to be used.
- Least squares estimation is used.
- Weighted least squares is used and weights must be supplied in array WT.
Constraint:
or .
- 2: N – INTEGERInput
On entry: , the number of observations.
Constraint:
.
- 3: WT() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
WT
must be at least
if
, and at least
otherwise.
On entry: if
>,
WT must contain the weights to be used in the weighted regression.
If , the th observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights.
If
,
WT is not referenced and the effective number of observations is
.
Constraint:
if , , for .
On entry: the residual sum of squares for the original dependent variable.
On exit: the residual sum of squares for the new dependent variable.
Constraint:
.
- 5: IP – INTEGERInput
On entry: , the number of independent variables (including the mean if fitted).
Constraint:
.
- 6: IRANK – INTEGERInput
On entry: the rank of the independent variables, as given by
G02DAF.
Constraint:
, and if , then , else .
- 7: COV() – REAL (KIND=nag_wp) arrayInput/Output
On entry: the covariance matrix of the parameter estimates as given by
G02DAF.
On exit: the upper triangular part of the variance-covariance matrix of the
IP parameter estimates given in
B. They are stored packed by column, i.e., the covariance between the parameter estimate given in
and the parameter estimate given in
,
, is stored in
.
- 8: Q(LDQ,) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the results of the
decomposition as returned by
G02DAF.
On exit: the first column of
Q contains the new values of
, the remainder of
Q will be unchanged.
- 9: LDQ – INTEGERInput
On entry: the first dimension of the array
Q as declared in the (sub)program from which G02DGF is called.
Constraint:
.
- 10: SVD – LOGICALInput
On entry: indicates if a singular value decomposition was used by
G02DAF.
- A singular value decomposition was used by G02DAF.
- A singular value decomposition was not used by G02DAF.
- 11: P() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
P
must be at least
if
, and at least
otherwise.
On entry: details of the
decomposition and SVD, if used, as returned in array
P by
G02DAF.
If
, only the first
IP elements of
P are used; these contain the zeta values for the
decomposition (see
F08AEF (DGEQRF) for details).
If
, the first
IP elements of
P contain the zeta values for the
decomposition (see
F08AEF (DGEQRF) for details) and the next
elements of
P contain details of the singular value decomposition.
- 12: Y(N) – REAL (KIND=nag_wp) arrayInput
On entry: the new dependent variable, .
- 13: B(IP) – REAL (KIND=nag_wp) arrayOutput
On exit: the least squares estimates of the parameters of the regression model, .
- 14: SE(IP) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard error of the estimates of the parameters.
- 15: RES(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the residuals for the new regression model.
- 16: WK() – REAL (KIND=nag_wp) arrayInput
On entry: if
,
WK must be unaltered from the previous call to
G02DAF or G02DGF.
If
,
WK is used as workspace.
- 17: 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 | and , |
or | and , |
or | , |
or | , |
or | or . |
-
On entry, | and a value of . |
7 Accuracy
The same accuracy as
G02DAF is obtained.
The values of the leverages,
, are unaltered by a change in the dependent variable so a call to
G02FAF can be made using the value of
H from
G02DAF.
9 Example
A dataset consisting of
observations with four independent variables and two dependent variables are read in. A model with all four independent variables is fitted to the first dependent variable by
G02DAF and the results printed. The model is then fitted to the second dependent variable by G02DGF and those results printed.
9.1 Program Text
Program Text (g02dgfe.f90)
9.2 Program Data
Program Data (g02dgfe.d)
9.3 Program Results
Program Results (g02dgfe.r)