hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_linregm_update (g02dd)

Purpose

nag_correg_linregm_update (g02dd) calculates the regression parameters for a general linear regression model. It is intended to be called after nag_correg_linregm_obs_edit (g02dc), nag_correg_linregm_var_add (g02de) or nag_correg_linregm_var_del (g02df).

Syntax

[rss, idf, b, se, cov, svd, irank, p, ifail] = g02dd(n, ip, q, rss, 'tol', tol)
[rss, idf, b, se, cov, svd, irank, p, ifail] = nag_correg_linregm_update(n, ip, q, rss, 'tol', tol)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: n has been made optional
Mark 23: n is now a compulsory input parameter, instead of optional. p is now output only, not input/output.
.

Description

A general linear regression model fitted by nag_correg_linregm_fit (g02da) may be adjusted by adding or deleting an observation using nag_correg_linregm_obs_edit (g02dc), adding a new independent variable using nag_correg_linregm_var_add (g02de) or deleting an existing independent variable using nag_correg_linregm_var_del (g02df). Alternatively a model may be constructed by a forward selection procedure using nag_correg_linregm_fit_onestep (g02ee). These functions compute the vector cc and the upper triangular matrix RR. nag_correg_linregm_update (g02dd) takes these basic results and computes the regression coefficients, β̂β^, their standard errors and their variance-covariance matrix.
If RR is of full rank, then β̂β^ is the solution to
Rβ̂ = c1,
Rβ^=c1,
where c1c1 is the first pp elements of cc.
If RR is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of RR,
R = Q*
(D0)
0 0
PT,
R=Q* D 0 0 0 PT,
where DD is a kk by kk diagonal matrix with nonzero diagonal elements, kk being the rank of RR, and Q*Q* and PP are pp by pp orthogonal matrices. This gives the solution
β̂ = P1D1Q*1Tc1.
β^=P1D-1Q*1Tc1.
P1P1 being the first kk columns of PP, i.e., P = (P1P0)P=(P1P0), and Q*1Q*1 being the first kk columns of Q*Q*.
Details of the SVD are made available in the form of the matrix P*P*:
P* =
(D1 P1T )
P0T
.
P*= D-1 P1T P0T .
This will be only one of the possible solutions. Other estimates may be obtained by applying constraints to the parameters. These solutions can be obtained by calling nag_correg_linregm_constrain (g02dk) after calling nag_correg_linregm_update (g02dd). Only certain linear combinations of the parameters will have unique estimates; these are known as estimable functions. These can be estimated using nag_correg_linregm_estfunc (g02dn).
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 cc for the whole sample is provided.

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

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
The number of observations.
Constraint: n1n1.
2:     ip – int64int32nag_int scalar
pp, the number of terms in the regression model.
Constraint: ip1ip1.
3:     q(ldq,ip + 1ip+1) – double array
ldq, the first dimension of the array, must satisfy the constraint
  • if rss0.0rss0.0, ldqnldqn;
  • otherwise ldqipldqip.
4:     rss – double scalar
Either the residual sum of squares or a value less than or equal to 0.00.0 to indicate that the residual sum of squares is to be calculated by the function.

Optional Input Parameters

1:     tol – double scalar
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 tol = 0.0tol=0.0, 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.
Default: 0.0000010.000001
Constraint: tol0.0tol0.0.

Input Parameters Omitted from the MATLAB Interface

ldq wk

Output Parameters

1:     rss – double scalar
If rss0.0rss0.0 on entry, then on exit rss will contain the residual sum of squares as calculated by nag_correg_linregm_update (g02dd).
If rss was positive on entry, it will be unchanged.
2:     idf – int64int32nag_int scalar
The degrees of freedom associated with the residual sum of squares.
3:     b(ip) – double array
The estimates of the pp parameters, β̂β^.
4:     se(ip) – double array
The standard errors of the pp parameters given in b.
5:     cov(ip × (ip + 1) / 2ip×(ip+1)/2) – double array
The upper triangular part of the variance-covariance matrix of the pp parameter estimates given in b. They are stored packed by column, i.e., the covariance between the parameter estimate given in b(i)bi and the parameter estimate given in b(j)bj, jiji, is stored in cov(j × (j1) / 2 + i)covj×(j-1)/2+i.
6:     svd – logical scalar
If a singular value decomposition has been performed, svd = truesvd=true, otherwise svd = falsesvd=false.
7:     irank – int64int32nag_int scalar
The rank of the independent variables.
If svd = falsesvd=false, irank = ipirank=ip.
If svd = truesvd=true, irank is an estimate of the rank of the independent variables.
irank is calculated as the number of singular values greater than tol × tol× (largest singular value). It is possible for the SVD to be carried out but irank to be returned as ip.
8:     p(ip × ip + 2 × ipip×ip+2×ip) – double array
Contains details of the singular value decomposition if used.
If svd = falsesvd=false, p is not referenced.
If svd = truesvd=true, the first ip elements of p will not be referenced, the next ip values contain the singular values. The following ip × ipip×ip values contain the matrix P*P* stored by columns.
9:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1,
orip < 1ip<1,
orldq < ipldq<ip,
orldq < nldq<n,
ortol < 0.0tol<0.0.
  ifail = 2ifail=2
The degrees of freedom for error are less than or equal to 00. In this case the estimates of ββ are returned but not the standard errors or covariances.
  ifail = 3ifail=3
The singular value decomposition, if used, has failed to converge, see nag_eigen_real_triang_svd (f02wu). This is an unlikely error exit.

Accuracy

The accuracy of the results will depend on the accuracy of the input RR matrix, which may lose accuracy if a large number of observations or variables have been dropped.

Further Comments

None.

Example

function nag_correg_linregm_update_example
n = int64(12);
ip = int64(4);
q = [-62.35960257517148, -1.732050807568877, 0, 0, 0;
     64.60549512231913, 0, 1.732050807568877, 0, 0;
     72.0590870975572, 0, -0.5773502691896258, 1.732050807568877, 0;
     -65.60431108801717, 0, -0, -0.5773502691896258, -1.732050807568877;
     -0.3146182873523283, 0, -0, -0, 0.5287121214812434;
     -0.7278845221914594, 0, -0.5773502691896258, -0, 0.305252085661014;
     -2.34461828735233, 0, -0, -0, 0.5287121214812434;
     1.44536695831506, 0.4597008433809831, -0, -0, 0;
     2.253195474436084, 0, -0, -0.5773502691896258, 0.1762373738270812;
     2.665366958315059, 0.4597008433809831, -0, -0, 0;
     -0.2368045255639181, 0, -0, -0.5773502691896258, 0.1762373738270812;
     1.332115477808543, 0, -0.5773502691896258, -0, 0.305252085661014];
rss = 0;
[rssOut, idf, b, se, covar, svd, irank, p, ifail] = nag_correg_linregm_update(n,ip, q, rss)
 

rssOut =

   22.2268


idf =

                    8


b =

   36.0033
   37.3000
   41.6033
   37.8767


se =

    0.9623
    0.9623
    0.9623
    0.9623


covar =

    0.9261
         0
    0.9261
         0
         0
    0.9261
         0
         0
         0
    0.9261


svd =

     0


irank =

                    4


p =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0


ifail =

                    0


function g02dd_example
n = int64(12);
ip = int64(4);
q = [-62.35960257517148, -1.732050807568877, 0, 0, 0;
     64.60549512231913, 0, 1.732050807568877, 0, 0;
     72.0590870975572, 0, -0.5773502691896258, 1.732050807568877, 0;
     -65.60431108801717, 0, -0, -0.5773502691896258, -1.732050807568877;
     -0.3146182873523283, 0, -0, -0, 0.5287121214812434;
     -0.7278845221914594, 0, -0.5773502691896258, -0, 0.305252085661014;
     -2.34461828735233, 0, -0, -0, 0.5287121214812434;
     1.44536695831506, 0.4597008433809831, -0, -0, 0;
     2.253195474436084, 0, -0, -0.5773502691896258, 0.1762373738270812;
     2.665366958315059, 0.4597008433809831, -0, -0, 0;
     -0.2368045255639181, 0, -0, -0.5773502691896258, 0.1762373738270812;
     1.332115477808543, 0, -0.5773502691896258, -0, 0.305252085661014];
rss = 0;
[rssOut, idf, b, se, covar, svd, irank, p, ifail] = g02dd(n,ip, q, rss)
 

rssOut =

   22.2268


idf =

                    8


b =

   36.0033
   37.3000
   41.6033
   37.8767


se =

    0.9623
    0.9623
    0.9623
    0.9623


covar =

    0.9261
         0
    0.9261
         0
         0
    0.9261
         0
         0
         0
    0.9261


svd =

     0


irank =

                    4


p =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013