The function may be called by the names: g02dgc, nag_correg_linregm_fit_newvar or nag_regsn_mult_linear_newyvar.
g02dgc uses the results given by g02dac to fit the same set of independent variables to a new dependent variable.
g02dac 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 arguments 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, , g02dgc 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 g02dac will have computed the 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 g02dac in the form of the matrix :
The matrix is made available through the com_ar argument of g02dac.
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.
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
1: – IntegerInput
On entry: the number of observations, .
2: – const doubleInput
On entry: optionally, the weights to be used in the weighted regression.
If , then 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. The values of res and h will be set to zero for observations with zero weights (see g02dac).
If weights are not provided then wt must be set to NULL and the effective number of observations is n.
if , , for .
3: – double *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.
4: – IntegerInput
On entry: the number of independent variables in the model (including the mean if fitted).
5: – IntegerInput
On entry: the rank of the independent variables, as given by g02dac.
and if , otherwise .
6: – doubleInput/Output
On entry: the covariance matrix of the parameter estimates as given by g02dac.
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 for and .
7: – doubleInput/Output
Note: the th element of the matrix is stored in .
On entry: the results of the decomposition as returned by g02dac.
On exit: the first column of q contains the new values of , the remainder of q will be unchanged.
8: – IntegerInput
On entry: the stride separating matrix column elements in the array q.
9: – Nag_BooleanInput
On entry: indicates if a singular value decomposition was used by g02dac.
A singular value decomposition was used by g02dac.
A singular value decomposition was not used by g02dac.
10: – const doubleInput
On entry: details of the decomposition and SVD, if used, as returned in array p by g02dac.
If , only the first ip elements of p are used, these
will contain details of the Householder vector in the decomposition (Sections 2.2.1 and 3.4.6 in the F08 Chapter Introduction).
If , the first ip elements of p
will contain details of the Householder vector in the decomposition (Sections 2.2.1 and 3.4.6 in the F08 Chapter Introduction) and the next ip elements of p contain singular values. The following ip by ip elements contain the matrix stored by rows.
11: – const doubleInput
On entry: the new dependent variable .
12: – doubleOutput
On exit: , contain the least squares estimates of the arguments of the regression model, .
13: – doubleOutput
On exit: , contain the standard errors of the ip parameter estimates given in b.
14: – doubleOutput
On exit: the residuals for the new regression model.
15: – const doubleInput
On entry: if , com_ar must be unaltered from the previous call to g02dac.
16: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
On entry, while . These arguments must satisfy .
On entry, while . These arguments must satisfy .
On entry, .
On entry, .
On entry, rss must not be less than or equal to 0.0: .
On entry, must not be less than 0.0: .
On entry, the Boolean variable, svd, is Nag_TRUE and rank must not be greater than ip: rank = , .
On entry, the Boolean variable, svd, is Nag_FALSE and rank must be equal to ip: , .
Background information to multithreading can be found in the Multithreading documentation.
g02dgc is not threaded in any implementation.
The values of the leverages, , are unaltered by a change in the dependent variable so a call to g02fac can be made using the value of h from g02dac.
Internal changes have been made to this function as follows:
At Mark 26.1: The documented minimum length of the array argument com_ar was too large. The documented minimum length was given as but the actual minimum length is which is much less for non-trivial cases, .
In addition, provided example programs that called g02dgc allocated lengths of for the array argument, which was also larger than necessary for non-trivial problems.
The g02dgc function document was updated to document the actual minimum length requirement for com_ar, and those example programs that call g02dgc have been updated to allocate the actual minimum length required for com_ar.
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.
A dataset consisting of 12 observations with four independent variables and two dependent variables is read in. A model with all four independent variables is fitted to the first dependent variable by g02dac and the results printed. The model is then fitted to the second dependent variable by g02dgc and those results printed.