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_glm_constrain (g02gk)

Purpose

nag_correg_glm_constrain (g02gk) calculates the estimates of the parameters of a generalized linear model for given constraints from the singular value decomposition results.

Syntax

[b, se, cov, ifail] = g02gk(v, c, b, s, 'ip', ip, 'iconst', iconst)
[b, se, cov, ifail] = nag_correg_glm_constrain(v, c, b, s, 'ip', ip, 'iconst', iconst)

Description

nag_correg_glm_constrain (g02gk) computes the estimates given a set of linear constraints for a generalized linear model which is not of full rank. It is intended for use after a call to nag_correg_glm_normal (g02ga), nag_correg_glm_binomial (g02gb), nag_correg_glm_poisson (g02gc) or nag_correg_glm_gamma (g02gd).
In the case of a model not of full rank the functions use a singular value decomposition to find the parameter estimates, β̂svdβ^svd, and their variance-covariance matrix. Details of the SVD are made available in the form of the matrix P*P*:
P* =
(D1 P1T )
P0T
P*= D-1 P1T P0T
as described by nag_correg_glm_normal (g02ga), nag_correg_glm_binomial (g02gb), nag_correg_glm_poisson (g02gc) and nag_correg_glm_gamma (g02gd). Alternative solutions can be formed by imposing constraints on the parameters. If there are pp parameters and the rank of the model is kk then nc = pknc=p-k constraints will have to be imposed to obtain a unique solution.
Let CC be a pp by ncnc matrix of constraints, such that
CTβ = 0,
CTβ=0,
then the new parameter estimates β̂cβ^c are given by:
β̂c = Aβ̂svd
= (IP0(CTP0)1)β̂svd,   where ​I​ is the identity matrix,
β^c =Aβ^svd =(I-P0(CTP0)-1)β^svd,   where ​I​ is the identity matrix,
and the variance-covariance matrix is given by
AP1D2 P1T AT
AP1D-2 P1T AT
provided (CTP0)1(CTP0)-1 exists.

References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall
Searle S R (1971) Linear Models Wiley

Parameters

Compulsory Input Parameters

1:     v(ldv,ip + 7ip+7) – double array
ldv, the first dimension of the array, must satisfy the constraint ldvipldvip..
2:     c(ldc,iconst) – double array
ldc, the first dimension of the array, must satisfy the constraint ldcipldcip.
Contains the iconst constraints stored by column, i.e., the iith constraint is stored in the iith column of c.
3:     b(ip) – double array
ip, the dimension of the array, must satisfy the constraint ip1ip1.
The parameter estimates computed by using the singular value decomposition, β̂svdβ^svd.
4:     s – double scalar
The estimate of the scale parameter.
For results from nag_correg_glm_normal (g02ga) and nag_correg_glm_gamma (g02gd) then s is the scale parameter for the model.
For results from nag_correg_glm_binomial (g02gb) and nag_correg_glm_poisson (g02gc) then s should be set to 1.01.0.
Constraint: s > 0.0s>0.0.

Optional Input Parameters

1:     ip – int64int32nag_int scalar
Default: The dimension of the array b and the first dimension of the arrays c, v. (An error is raised if these dimensions are not equal.)
pp, the number of terms in the linear model.
Constraint: ip1ip1.
2:     iconst – int64int32nag_int scalar
Default: The second dimension of the array c.
The number of constraints to be imposed on the parameters, ncnc.
Constraint: 0 < iconst < ip0<iconst<ip.

Input Parameters Omitted from the MATLAB Interface

ldv ldc wk

Output Parameters

1:     b(ip) – double array
The parameter estimates of the parameters with the constraints imposed, β̂cβ^c.
2:     se(ip) – double array
The standard error of the parameter estimates in b.
3:     cov(ip × (ip + 1) / 2ip×(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 b(i)bi and the parameter estimate given in b(j)bj, jiji, is stored in cov((j × (j1) / 2 + i))cov(j×(j-1)/2+i).
4:     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,ip < 1ip<1.
oriconstipiconstip,
oriconst0iconst0,
orldv < ipldv<ip,
orldc < ipldc<ip,
ors0.0s0.0.
  ifail = 2ifail=2
c does not give a model of full rank.

Accuracy

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

Further Comments

nag_correg_glm_constrain (g02gk) is intended for use in situations in which dummy (0101) variables have been used such as in the analysis of designed experiments when you do not wish to change the parameters 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

function nag_correg_glm_constrain_example
v = [4.890297476493481, 132.9931304975522, 0.08671323636775569, 11.53226476012202, ...
    0.6875039713237874, 0.6035396163882434, 0, 0.0190106784478845, 0.008405335397184037, ...
     0.008587821997748737, 0.002017521052951722, 0.006018698150011753, ...
    0.002569439508216107, 0.005710268118949224, 0.003195800397035001, 0.001516472273672414;
     4.150630280659896, 63.47399412403458, 0.1255168658332746, 7.96705680436851, ...
    0.4385677120269487, 0.5137644803624514, 0, -0.0002104052850739208, -0.03362644601906961, ...
    0.03352834001769896, -0.0001122992837032618, -8.410523978672018e-05, ...
    -1.834202533241677e-05, -7.350180559025446e-05, -2.50373181392074e-05, -9.418896225321663e-06;
     4.847173050021614, 127.3797841010689, 0.08860326907783028, 11.28626528578293, ...
    -1.207211262022778, 0.5962906923855547, 0, -0.000593266263451917, -0.0003445349204235381, ...
     -0.000333175581116977, 8.444423808860036e-05, 0.04164067761137802, ...
    -0.000834602710139113, -0.03974432490123243, -0.001281738894244829, -0.0003732773692135418;
     4.347583499449088, 77.29146221158076, 0.1137455037136346, 8.791556302019613, ...
    0.193629026736895, 0.5316079856446033, 0, -0.005604448606553034, -0.00473076223435367, ...
     -0.004660408745794929, 0.003786722373595579, 0.03079195529372083, ...
    -0.01961182893501804, 0.03434336417204345, -0.04455401443460466, -0.006573924702694605;
     3.660007365784039, 38.86162911664574, 0.160412976990412, 6.23390961729842, ...
    0.02218333268101244, 0.4819807366090336, 0, -0.01246501079735563, 0.02562719062269757, ...
     0.02538801446619446, -0.06348021588624767, -0.003268009116713865, ...
    0.01218311975746848, -0.003443738617825787, -0.01974708083814387, 0.001810698017859427;
     4.906081344202832, 135.1089303020151, 0.08603159451608589, 11.62363670724507, ...
    -0.3553126814370362, 0.6083327470988832, 0, -0.007494797532342946, 0.006087596749368498, ...
     0.006034528387724169, -0.01961692266943561, 0.009789429893167587, ...
    -0.06230084141169696, 0.01026746382279108, 0.04102802603588968, -0.006278875872494353;
     4.166414148369245, 64.48380766743846, 0.1245301935277972, 8.030181048235367, ...
    0.1880789664600944, 0.5196429754104227, 0, -0.007856295692343652, -0.001520639263699578, ...
     -0.001513684000176248, -0.004821972428467818, 0.01450100243772308, ...
    0.03053649776467425, 0.01481400539841174, 0.02215701246445583, -0.08986481375760852;
     4.862956917730965, 129.4062806673598, 0.08790676991659417, 11.37568814038781, ...
    1.174924303092439, 0.6011714612100958, 0, 0.4644148349507297, -0.508180337140321, ...
     -0.508180337140321, -0.508180337140321, 0.04376550218959127, ...
    0.04376550218959111, 0.04376550218959127, 0.04376550218959124, 0.04376550218959125;
     4.363367367158438, 78.52109911103648, 0.1128513646061788, 8.861213185057478, ...
    -0.7464706890225739, 0.5372707561039687, 0, -0.3635174659273034, -0.05120849696428324, ...
     -0.05120849696428324, -0.05120849696428316, 0.4147259628915867, ...
    0.4147259628915865, 0.4147259628915868, 0.4147259628915868, 0.4147259628915868];
c = [0, 0;
     1, 0;
     1, 0;
     1, 0;
     0, 1;
     0, 1;
     0, 1;
     0, 1;
     0, 1];
b = [2.597657842414576;
     1.261948923584132;
     1.277732791293482;
     0.05797612753696259;
     1.030690710494773;
     0.2910235146611871;
     0.9875662840229057;
     0.4879767334503795;
     -0.1995994002146691];
s = 1;
[bOut, se, covar, ifail] = nag_correg_glm_constrain(v, c, b, s)
 

bOut =

    3.9831
    0.3961
    0.4118
   -0.8079
    0.5112
   -0.2285
    0.4680
   -0.0316
   -0.7191


se =

    0.0396
    0.0458
    0.0457
    0.0622
    0.0562
    0.0727
    0.0569
    0.0675
    0.0887


covar =

    0.0016
   -0.0006
    0.0021
   -0.0006
   -0.0002
    0.0021
    0.0012
   -0.0019
   -0.0019
    0.0039
   -0.0006
    0.0000
   -0.0000
    0.0000
    0.0032
    0.0002
   -0.0000
    0.0000
   -0.0000
   -0.0008
    0.0053
   -0.0005
    0.0000
   -0.0000
   -0.0000
   -0.0001
   -0.0008
    0.0032
   -0.0001
    0.0000
   -0.0000
   -0.0000
   -0.0006
   -0.0013
   -0.0006
    0.0046
    0.0010
   -0.0000
    0.0000
    0.0000
   -0.0017
   -0.0024
   -0.0017
   -0.0021
    0.0079


ifail =

                    0


function g02gk_example
v = [4.890297476493481, 132.9931304975522, 0.08671323636775569, 11.53226476012202, ...
    0.6875039713237874, 0.6035396163882434, 0, 0.0190106784478845, 0.008405335397184037, ...
     0.008587821997748737, 0.002017521052951722, 0.006018698150011753, ...
    0.002569439508216107, 0.005710268118949224, 0.003195800397035001, 0.001516472273672414;
     4.150630280659896, 63.47399412403458, 0.1255168658332746, 7.96705680436851, ...
    0.4385677120269487, 0.5137644803624514, 0, -0.0002104052850739208, -0.03362644601906961, ...
    0.03352834001769896, -0.0001122992837032618, -8.410523978672018e-05, ...
    -1.834202533241677e-05, -7.350180559025446e-05, -2.50373181392074e-05, -9.418896225321663e-06;
     4.847173050021614, 127.3797841010689, 0.08860326907783028, 11.28626528578293, ...
    -1.207211262022778, 0.5962906923855547, 0, -0.000593266263451917, -0.0003445349204235381, ...
     -0.000333175581116977, 8.444423808860036e-05, 0.04164067761137802, ...
    -0.000834602710139113, -0.03974432490123243, -0.001281738894244829, -0.0003732773692135418;
     4.347583499449088, 77.29146221158076, 0.1137455037136346, 8.791556302019613, ...
    0.193629026736895, 0.5316079856446033, 0, -0.005604448606553034, -0.00473076223435367, ...
     -0.004660408745794929, 0.003786722373595579, 0.03079195529372083, ...
    -0.01961182893501804, 0.03434336417204345, -0.04455401443460466, -0.006573924702694605;
     3.660007365784039, 38.86162911664574, 0.160412976990412, 6.23390961729842, ...
    0.02218333268101244, 0.4819807366090336, 0, -0.01246501079735563, 0.02562719062269757, ...
     0.02538801446619446, -0.06348021588624767, -0.003268009116713865, ...
    0.01218311975746848, -0.003443738617825787, -0.01974708083814387, 0.001810698017859427;
     4.906081344202832, 135.1089303020151, 0.08603159451608589, 11.62363670724507, ...
    -0.3553126814370362, 0.6083327470988832, 0, -0.007494797532342946, 0.006087596749368498, ...
     0.006034528387724169, -0.01961692266943561, 0.009789429893167587, ...
    -0.06230084141169696, 0.01026746382279108, 0.04102802603588968, -0.006278875872494353;
     4.166414148369245, 64.48380766743846, 0.1245301935277972, 8.030181048235367, ...
    0.1880789664600944, 0.5196429754104227, 0, -0.007856295692343652, -0.001520639263699578, ...
     -0.001513684000176248, -0.004821972428467818, 0.01450100243772308, ...
    0.03053649776467425, 0.01481400539841174, 0.02215701246445583, -0.08986481375760852;
     4.862956917730965, 129.4062806673598, 0.08790676991659417, 11.37568814038781, ...
    1.174924303092439, 0.6011714612100958, 0, 0.4644148349507297, -0.508180337140321, ...
     -0.508180337140321, -0.508180337140321, 0.04376550218959127, ...
    0.04376550218959111, 0.04376550218959127, 0.04376550218959124, 0.04376550218959125;
     4.363367367158438, 78.52109911103648, 0.1128513646061788, 8.861213185057478, ...
    -0.7464706890225739, 0.5372707561039687, 0, -0.3635174659273034, -0.05120849696428324, ...
     -0.05120849696428324, -0.05120849696428316, 0.4147259628915867, ...
    0.4147259628915865, 0.4147259628915868, 0.4147259628915868, 0.4147259628915868];
c = [0, 0;
     1, 0;
     1, 0;
     1, 0;
     0, 1;
     0, 1;
     0, 1;
     0, 1;
     0, 1];
b = [2.597657842414576;
     1.261948923584132;
     1.277732791293482;
     0.05797612753696259;
     1.030690710494773;
     0.2910235146611871;
     0.9875662840229057;
     0.4879767334503795;
     -0.1995994002146691];
s = 1;
[bOut, se, covar, ifail] = g02gk(v, c, b, s)
 

bOut =

    3.9831
    0.3961
    0.4118
   -0.8079
    0.5112
   -0.2285
    0.4680
   -0.0316
   -0.7191


se =

    0.0396
    0.0458
    0.0457
    0.0622
    0.0562
    0.0727
    0.0569
    0.0675
    0.0887


covar =

    0.0016
   -0.0006
    0.0021
   -0.0006
   -0.0002
    0.0021
    0.0012
   -0.0019
   -0.0019
    0.0039
   -0.0006
    0.0000
   -0.0000
    0.0000
    0.0032
    0.0002
   -0.0000
    0.0000
   -0.0000
   -0.0008
    0.0053
   -0.0005
    0.0000
   -0.0000
   -0.0000
   -0.0001
   -0.0008
    0.0032
   -0.0001
    0.0000
   -0.0000
   -0.0000
   -0.0006
   -0.0013
   -0.0006
    0.0046
    0.0010
   -0.0000
    0.0000
    0.0000
   -0.0017
   -0.0024
   -0.0017
   -0.0021
    0.0079


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