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_constrain (g02dk)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_correg_linregm_constrain (g02dk) calculates the estimates of the arguments of a general linear regression model for given constraints from the singular value decomposition results.

Syntax

[b, se, covar, ifail] = g02dk(p, c, b, rss, idf, 'ip', ip, 'iconst', iconst)
[b, se, covar, ifail] = nag_correg_linregm_constrain(p, c, b, rss, idf, 'ip', ip, 'iconst', iconst)

Description

nag_correg_linregm_constrain (g02dk) computes the estimates given a set of linear constraints for a general linear regression model which is not of full rank. It is intended for use after a call to nag_correg_linregm_fit (g02da) or nag_correg_linregm_update (g02dd).
In the case of a model not of full rank the functions use a singular value decomposition (SVD) to find the parameter estimates, β^svd, and their variance-covariance matrix. Details of the SVD are made available in the form of the matrix P*:
P*= D-1 P1T P0T ,  
as described by nag_correg_linregm_fit (g02da) and nag_correg_linregm_update (g02dd).
Alternative solutions can be formed by imposing constraints on the arguments. If there are p arguments and the rank of the model is k, then nc=p-k constraints will have to be imposed to obtain a unique solution.
Let C be a p by nc matrix of constraints, such that
CTβ=0  
then the new parameter estimates β^c are given by
β^c =Aβ^svd; =I-P0CTP0-1β^svd,  
where I is the identity matrix, and the variance-covariance matrix is given by
AP1D-2P1TAT,  
provided CTP0-1 exists.

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:     pip×ip+2×ip – double array
2:     cldciconst – double array
ldc, the first dimension of the array, must satisfy the constraint ldcip.
The iconst constraints stored by column, i.e., the ith constraint is stored in the ith column of c.
3:     bip – double array
The parameter estimates computed by using the singular value decomposition, β^svd.
4:     rss – double scalar
The residual sum of squares as returned by nag_correg_linregm_fit (g02da) or nag_correg_linregm_update (g02dd).
Constraint: rss>0.0.
5:     idf int64int32nag_int scalar
The degrees of freedom associated with the residual sum of squares as returned by nag_correg_linregm_fit (g02da) or nag_correg_linregm_update (g02dd).
Constraint: idf>0.

Optional Input Parameters

1:     ip int64int32nag_int scalar
Default: the dimension of the array b and the first dimension of the array c. (An error is raised if these dimensions are not equal.)
p, the number of terms in the linear model.
Constraint: ip1.
2:     iconst int64int32nag_int scalar
Default: the second dimension of the array c.
The number of constraints to be imposed on the arguments, nc.
Constraint: 0<iconst<ip.

Output Parameters

1:     bip – double array
The parameter estimates of the arguments with the constraints imposed, β^c.
2:     seip – double array
The standard error of the parameter estimates in b.
3:     covarip×ip+1/2 – double array
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 bi and the parameter estimate given in bj, ji, is stored in covarj×j-1/2+i.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,ip<1,
oriconst0,
oriconstip,
orldc<ip,
orrss0.0,
oridf0.
   ifail=2
c does not give a model of full rank.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

It should be noted that due to rounding errors a argument that should be zero when the constraints have been imposed may be returned as a value of order machine precision.

Further Comments

nag_correg_linregm_constrain (g02dk) is intended for use in situations in which dummy (01) variables have been used such as in the analysis of designed experiments when you do not wish to change the arguments of the model to give a full rank model. The function is not intended for situations in which the relationships between the independent variables are only approximate.

Example

Data from an experiment with four treatments and three observations per treatment are read in. A model, including the mean term, is fitted by nag_correg_linregm_fit (g02da) and the results printed. The constraint that the sum of treatment effect is zero is then read in and the parameter estimates with this constraint imposed are computed by nag_correg_linregm_constrain (g02dk) and printed.
function g02dk_example


fprintf('g02dk example results\n\n');

x = [1, 0, 0, 0;
     0, 0, 0, 1;
     0, 1, 0, 0;
     0, 0, 1, 0;
     0, 0, 0, 1;
     0, 1, 0, 0;
     0, 0, 0, 1;
     1, 0, 0, 0;
     0, 0, 1, 0;
     1, 0, 0, 0;
     0, 0, 1, 0;
     0, 1, 0, 0];
y = [33.63;     39.62;     38.18;     41.46;     38.02;     35.83;
     35.99;     36.58;     42.92;     37.80;     40.43;     37.89];

[n,m]  = size(x);
isx    = ones(m,1,'int64');
mean_p = 'M';
ip     = int64(m+1);

% Fit general linear regression model
[rss, idf, b, se, covar, res, h, q, svd, irank, p, wk, ifail] = ...
  g02da(mean_p, x, isx, ip, y);

% Display initial estimate results
fprintf('Initial estimates\n\n');
fprintf('Residual sum of squares = %12.4e\n', rss);
fprintf('Degrees of freedom      = %4d\n', idf);
fprintf('\nVariable   Parameter estimate   Standard error\n\n');
ivar = double([1:ip]');
fprintf('%6d%20.4e%20.4e\n',[ivar b se]');

% Constraints
c = ones(ip,ip-irank);
c(1,1) = 0;

% Re-estimate using constraints
[b, se, covar, ifail] = g02dk( ...
                               p, c, b, rss, idf);

% Display constrined estimates
fprintf('\nEstimates using constraints\n\n');
fprintf('Variable   Parameter estimate   Standard error\n\n');
ivar = double([1:ip]');
fprintf('%6d%20.4e%20.4e\n',[ivar b se]');


g02dk example results

Initial estimates

Residual sum of squares =   2.2227e+01
Degrees of freedom      =    8

Variable   Parameter estimate   Standard error

     1          3.0557e+01          3.8494e-01
     2          5.4467e+00          8.3896e-01
     3          6.7433e+00          8.3896e-01
     4          1.1047e+01          8.3896e-01
     5          7.3200e+00          8.3896e-01

Estimates using constraints

Variable   Parameter estimate   Standard error

     1          3.8196e+01          4.8117e-01
     2         -2.1925e+00          8.3342e-01
     3         -8.9583e-01          8.3342e-01
     4          3.4075e+00          8.3342e-01
     5         -3.1917e-01          8.3342e-01

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–2015