The routine may be called by the names g02dgf or nagf_correg_linregm_fit_newvar.
3Description
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 matrix and an 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 diagonal matrix with nonzero diagonal elements, being the rank of , and and are 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.
4References
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
5Arguments
1: – 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: – IntegerInput
On entry: , the number of observations.
Constraint:
.
3: – Real (Kind=nag_wp) arrayInput
Note: the dimension of the array wt
must be at least
if .
On entry: if wt must contain the weights to be used with the model.
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 .
4: – Real (Kind=nag_wp)Input/Output
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: – IntegerInput
On entry: , the number of independent variables (including the mean if fitted).
Constraint:
.
6: – IntegerInput
On entry: the rank of the independent variables, as given by g02daf.
Constraint:
, and if , then , else .
7: – 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: – 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: – IntegerInput
On entry: the first dimension of the array q as declared in the (sub)program from which g02dgf is called.
Constraint:
.
10: – 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: – 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 for details).
If , the first ip elements of p contain the zeta values for the decomposition (see f08aef for details) and the next elements of p contain details of the singular value decomposition.
12: – Real (Kind=nag_wp) arrayInput
On entry: the new dependent variable, .
13: – Real (Kind=nag_wp) arrayOutput
On exit: the least squares estimates of the parameters of the regression model, .
14: – Real (Kind=nag_wp) arrayOutput
On exit: the standard error of the estimates of the parameters.
15: – Real (Kind=nag_wp) arrayOutput
On exit: the residuals for the new regression model.
16: – Real (Kind=nag_wp) arrayInput
On entry: if , wk must be unaltered from the previous call to g02daf or g02dgf.
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or 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).
6Error 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, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: or .
On entry, .
Constraint: , for .
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.
Background information to multithreading can be found in the Multithreading documentation.
g02dgf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02dgf 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.
9Further Comments
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.
10Example
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.