NAG CL Interface
g02ddc (linregm_update)
1
Purpose
g02ddc calculates the regression arguments for a general linear regression model. It is intended to be called after
g02dcc,
g02dec or
g02dfc.
2
Specification
void |
g02ddc (Integer n,
Integer ip,
const double q[],
Integer tdq,
double *rss,
double *df,
double b[],
double se[],
double cov[],
Nag_Boolean *svd,
Integer *rank,
double p[],
double tol,
NagError *fail) |
|
The function may be called by the names: g02ddc, nag_correg_linregm_update or nag_regsn_mult_linear_upd_model.
3
Description
A general linear regression model fitted by
g02dac may be adjusted by adding or deleting an observation using
g02dcc, adding a new independent variable using
g02dec or deleting an existing independent variable using
g02dfc. These functions compute the vector
and the upper triangular matrix
.
g02ddc takes these basic results and computes the regression coefficients,
, their standard errors and their variance-covariance matrix.
If
is of full rank, then
is the solution to:
where
is the first
elements of
.
If
is not of full rank a solution is obtained by means of a singular value decomposition (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, in the form of the matrix
:
This will be only one of the possible solutions. Other estimates may be obtained by applying constraints to the arguments. These solutions can be obtained by calling
g02dkc after calling
g02ddc. Only certain linear combinations of the arguments will have unique estimates, these are known as estimable functions. These can be estimated using
g02dnc.
The residual sum of squares required to calculate the standard errors and the variance-covariance matrix can either be input or can be calculated if additional information on for the whole sample is provided.
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
Arguments
-
1:
– Integer
Input
-
On entry: number of observations.
Constraint:
.
-
2:
– Integer
Input
-
On entry: the number of terms in the regression model, .
Constraint:
.
-
3:
– const double
Input
-
Note: the th element of the matrix is stored in .
On entry:
q must be the array
q as output by
g02dcc,
g02dec or
g02dfc. If on entry
then all
n elements of
are needed. This is provided by functions
g02dec or
g02dfc.
-
4:
– Integer
Input
-
On entry: the stride separating matrix column elements in the array
q.
Constraint:
.
-
On entry: either the residual sum of squares or a value less than or equal to to indicate that the residual sum of squares is to be calculated by the function.
On exit: if
on entry, then on exit
rss will contain the residual sum of squares as calculated by
g02ddc.
If
rss was positive on entry, then it will be unchanged.
-
6:
– double *
Output
-
On exit: the degrees of freedom associated with the residual sum of squares.
-
7:
– double
Output
-
On exit: the estimates of the arguments, .
-
8:
– double
Output
-
On exit: the standard errors of the
arguments given in
b.
-
9:
– double
Output
-
On exit: the upper triangular part of the variance-covariance matrix of the
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
.
-
10:
– Nag_Boolean *
Output
-
On exit: if a singular value decomposition has been performed, then , otherwise .
-
11:
– Integer *
Output
-
On exit: the rank of the independent variables.
If , .
If
,
rank is an estimate of the rank of the independent variables.
rank is calculated as the number of singular values greater than
(largest singular value). It is possible for the singular value decomposition to be carried out but
rank to be returned as
ip.
-
12:
– double
Output
-
On exit:
p contains details of the singular value decomposition if used.
If
,
p is not referenced.
If
, the first
ip elements of
p will not be referenced, the next
ip values contain the singular values. The following
values contain the matrix
stored by rows.
-
13:
– double
Input
-
On entry: the value of
tol is used to decide if the independent variables are of full rank and, if not, what is the rank of the independent variables. The smaller the value of
tol the stricter the criterion for selecting the singular value decomposition. If
, then the singular value decomposition will never be used, this may cause run time errors or inaccuracies if the independent variables are not of full rank.
Suggested value:
.
Constraint:
.
-
14:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_DOF_LE_ZERO
-
The degrees of freedom for error are less than or equal to . In this case the estimates, , are returned but not the standard errors or covariances.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_REAL_ARG_LT
-
On entry,
tol must not be less than 0.0:
.
- NE_SVD_NOT_CONV
-
The singular value decomposition has failed to converge. This is an unlikely error exit.
7
Accuracy
The accuracy of the results will depend on the accuracy of the input matrix, which may lose accuracy if a large number of observations or variables have been dropped.
8
Parallelism and Performance
g02ddc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02ddc 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
10
Example
A dataset consisting of 12 observations and four independent variables is input and a regression model fitted by calls to
g02dec. The arguments are then calculated by
g02ddc and the results printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results