NAG Library Function Document
nag_regsn_mult_linear_upd_model (g02ddc)
1
Purpose
nag_regsn_mult_linear_upd_model (g02ddc) calculates the regression arguments for a general linear regression model. It is intended to be called after
nag_regsn_mult_linear_addrem_obs (g02dcc),
nag_regsn_mult_linear_add_var (g02dec) or
nag_regsn_mult_linear_delete_var (g02dfc).
2
Specification
#include <nag.h> |
#include <nagg02.h> |
void |
nag_regsn_mult_linear_upd_model (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) |
|
3
Description
A general linear regression model fitted by
nag_regsn_mult_linear (g02dac) may be adjusted by adding or deleting an observation using
nag_regsn_mult_linear_addrem_obs (g02dcc), adding a new independent variable using
nag_regsn_mult_linear_add_var (g02dec) or deleting an existing independent variable using
nag_regsn_mult_linear_delete_var (g02dfc). These functions compute the vector
and the upper triangular matrix
.
nag_regsn_mult_linear_upd_model (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
nag_regsn_mult_linear_tran_model (g02dkc) after calling
nag_regsn_mult_linear_upd_model (g02ddc). Only certain linear combinations of the arguments will have unique estimates, these are known as estimable functions. These can be estimated using
nag_regsn_mult_linear_est_func (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:
– IntegerInput
-
On entry: number of observations.
Constraint:
.
- 2:
– IntegerInput
-
On entry: the number of terms in the regression model, .
Constraint:
.
- 3:
– const doubleInput
-
Note: the th element of the matrix is stored in .
- 4:
– IntegerInput
-
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 0.0 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
nag_regsn_mult_linear_upd_model (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:
– doubleOutput
-
On exit: the estimates of the arguments, .
- 8:
– doubleOutput
-
On exit: the standard errors of the
arguments given in
b.
- 9:
– doubleOutput
-
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:
– doubleOutput
-
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:
– doubleInput
-
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 3.7 in How to Use the NAG Library and its Documentation).
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 0. 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
nag_regsn_mult_linear_upd_model (g02ddc) is not threaded in any implementation.
None.
10
Example
A dataset consisting of 12 observations and four independent variables is input and a regression model fitted by calls to
nag_regsn_mult_linear_add_var (g02dec). The arguments are then calculated by
nag_regsn_mult_linear_upd_model (g02ddc) and the results printed.
10.1
Program Text
Program Text (g02ddce.c)
10.2
Program Data
Program Data (g02ddce.d)
10.3
Program Results
Program Results (g02ddce.r)