Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_correg_glm_gamma (g02gd)

## Purpose

nag_correg_glm_gamma (g02gd) fits a generalized linear model with gamma errors.

## Syntax

[s, dev, idf, b, irank, se, cov, v, ifail] = g02gd(link, mean, x, isx, ip, y, s, 'n', n, 'm', m, 'wt', wt, 'a', a, 'v', v, 'tol', tol, 'maxit', maxit, 'iprint', iprint, 'eps', eps)
[s, dev, idf, b, irank, se, cov, v, ifail] = nag_correg_glm_gamma(link, mean, x, isx, ip, y, s, 'n', n, 'm', m, 'wt', wt, 'a', a, 'v', v, 'tol', tol, 'maxit', maxit, 'iprint', iprint, 'eps', eps)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: offset & weight omitted; v, wt, tol, maxit, iprint, eps, a optional
.

## Description

A generalized linear model with gamma errors consists of the following elements:
(a) a set of n$n$ observations, yi${y}_{i}$, from a gamma distribution with probability density function:
 1/(Γ(ν)) ((νy)/μ)νexp( − (νy)/μ) 1/y $1Γ(ν) (νy μ ) νexp(-νy μ ) 1y$
ν$\nu$ being constant for the sample.
(b) X$X$, a set of p$p$ independent variables for each observation, x1,x2,,xp${x}_{1},{x}_{2},\dots ,{x}_{p}$.
(c) a linear model:
 η = ∑ βjxj. $η=∑βjxj.$
(d) a link between the linear predictor, η$\eta$, and the mean of the distribution, μ$\mu$, η = g(μ)$\eta =g\left(\mu \right)$. The possible link functions are:
 (i) exponent link: η = μa$\eta ={\mu }^{a}$, for a constant a$a$, (ii) identity link: η = μ$\eta =\mu$, (iii) log link: η = logμ$\eta =\mathrm{log}\mu$, (iv) square root link: η = sqrt(μ)$\eta =\sqrt{\mu }$, (v) reciprocal link: η = 1/μ $\eta =\frac{1}{\mu }$.
(e) a measure of fit, an adjusted deviance. This is a function related to the deviance, but defined for y = 0$y=0$:
 n n ∑ dev*(yi,μ̂i) = ∑ 2(log(μ̂i) + ((yi)/(μ̂i))). i = 1 i = 1
$∑i=1ndev*(yi,μ^i)=∑i=1n2 (log(μ^i)+(yiμ^i) ) .$
The linear parameters are estimated by iterative weighted least squares. An adjusted dependent variable, z$z$, is formed:
 z = η + (y − μ)(dη)/(dμ) $z=η+(y-μ)dη dμ$
and a working weight, w$w$,
 w = (τ(dη)/(dμ))2,   where  τ = 1/μ. $w= (τdη dμ ) 2 , where τ=1μ.$
At each iteration an approximation to the estimate of β$\beta$, β̂$\stackrel{^}{\beta }$ is found by the weighted least squares regression of z$z$ on X$X$ with weights w$w$.
nag_correg_glm_gamma (g02gd) finds a QR$QR$ decomposition of w(1/2)X${w}^{\frac{1}{2}}X$, i.e.,
• w(1/2)X = QR${w}^{\frac{1}{2}}X=QR$ where R$R$ is a p$p$ by p$p$ triangular matrix and Q$Q$ is an n$n$ by p$p$ column orthogonal matrix.
If R$R$ is of full rank then β̂$\stackrel{^}{\beta }$ is the solution to:
• Rβ̂ = QTw(1/2)z$R\stackrel{^}{\beta }={Q}^{\mathrm{T}}{w}^{\frac{1}{2}}z$
If R$R$ is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of R$R$.
R = Q*
 ( D 0 ) 0 0
PT.
$R=Q* D 0 0 0 PT.$
where D$D$ is a k$k$ by k$k$ diagonal matrix with nonzero diagonal elements, k$k$ being the rank of R$R$ and w(1/2)X${w}^{\frac{1}{2}}X$.
This gives the solution
β̂ = P1D1
 ( Q* 0 ) 0 I
QTw(1/2)z,
$β^=P1D-1 Q* 0 0 I QTw12z,$
where P1${P}_{1}$ is the first k$k$ columns of P$P$, i.e., P = (P1P0)$P=\left({P}_{1}{P}_{0}\right)$.
The iterations are continued until there is only a small change in the deviance.
The initial values for the algorithm are obtained by taking
 η̂ = g(y). $η^=g(y).$
The scale parameter, ν1${\nu }^{-1}$ is estimated by a moment estimator:
 n ν̂ − 1 = ∑ ( [(yi − μ̂i) / μ̂] 2 )/((n − k)). i = 1
$ν^ -1 = ∑ i=1 n [ ( yi - μ^i ) / μ^ ] 2 (n-k) .$
The fit of the model can be assessed by examining and testing the deviance, in particular, by comparing the difference in deviance between nested models, i.e., when one model is a sub-model of the other. The difference in deviance or adjusted deviance between two nested models with known ν$\nu$ has, asymptotically, a χ2${\chi }^{2}$-distribution with degrees of freedom given by the difference in the degrees of freedom associated with the two deviances.
The parameters estimates, β̂$\stackrel{^}{\beta }$, are asymptotically Normally distributed with variance-covariance matrix:
• C = R1R1Tν1$C={R}^{-1}{{R}^{-1}}^{\mathrm{T}}{\nu }^{-1}$ in the full rank case, otherwise
• C = P1D2P1Tν1$C={P}_{1}{D}^{-2}{P}_{1}^{\mathrm{T}}{\nu }^{-1}$.
The residuals and influence statistics can also be examined.
The estimated linear predictor η̂ = Xβ̂$\stackrel{^}{\eta }=X\stackrel{^}{\beta }$, can be written as Hw(1/2)z$H{w}^{\frac{1}{2}}z$ for an n$n$ by n$n$ matrix H$H$. The i$i$th diagonal elements of H$H$, hi${h}_{i}$, give a measure of the influence of the i$i$th values of the independent variables on the fitted regression model. These are known as leverages.
The fitted values are given by μ̂ = g1(η̂)$\stackrel{^}{\mu }={g}^{-1}\left(\stackrel{^}{\eta }\right)$.
nag_correg_glm_gamma (g02gd) also computes the Anscombe residuals, r$r$:
 ri = ( 3 (yi(1/3) − μ̂i(1/3)) )/( μ̂i(1/3) ) . $ri = 3 ( y i 13 - μ^ i 13 ) μ^ i 13 .$
An option allows the use of prior weights, ωi${\omega }_{i}$. This gives a model with:
 νi = νωi . $νi = νωi .$
In many linear regression models the first term is taken as a mean term or an intercept, i.e., xi,1 = 1 ${x}_{i,1}=1$, for i = 1,2,,n $i=1,2,\dots ,n$. This is provided as an option.
Often only some of the possible independent variables are included in a model, the facility to select variables to be included in the model is provided.
If part of the linear predictor can be represented by a variables with a known coefficient then this can be included in the model by using an offset, o$o$:
 η = o + ∑ βj xj . $η = o + ∑ βj xj .$
If the model is not of full rank the solution given 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 using nag_correg_glm_constrain (g02gk) after using nag_correg_glm_gamma (g02gd). Only certain linear combinations of the parameters will have unique estimates, these are known as estimable functions, and can be estimated and tested using nag_correg_glm_estfunc (g02gn).
Details of the SVD are made available in the form of the matrix P*${P}^{*}$:
P* =
 ( D − 1 P1T ) P0T
.
$P* = D-1 P1T P0T .$

## References

Cook R D and Weisberg S (1982) Residuals and Influence in Regression Chapman and Hall
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall

## Parameters

### Compulsory Input Parameters

Indicates which link function is to be used.
link = 'E'${\mathbf{link}}=\text{'E'}$
link = 'I'${\mathbf{link}}=\text{'I'}$
link = 'L'${\mathbf{link}}=\text{'L'}$
link = 'S'${\mathbf{link}}=\text{'S'}$
A square root link is used.
link = 'R'${\mathbf{link}}=\text{'R'}$
Constraint: link = 'E'${\mathbf{link}}=\text{'E'}$, 'I'$\text{'I'}$, 'L'$\text{'L'}$, 'S'$\text{'S'}$ or 'R'$\text{'R'}$.
2:     mean – string (length ≥ 1)
Indicates if a mean term is to be included.
mean = 'M'${\mathbf{mean}}=\text{'M'}$
A mean term, intercept, will be included in the model.
mean = 'Z'${\mathbf{mean}}=\text{'Z'}$
The model will pass through the origin, zero-point.
Constraint: mean = 'M'${\mathbf{mean}}=\text{'M'}$ or 'Z'$\text{'Z'}$.
3:     x(ldx,m) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxn$\mathit{ldx}\ge {\mathbf{n}}$.
x(i,j)${\mathbf{x}}\left(\mathit{i},\mathit{j}\right)$ must contain the i$\mathit{i}$th observation for the j$\mathit{j}$th independent variable, for i = 1,2,,n$\mathit{i}=1,2,\dots ,{\mathbf{n}}$ and j = 1,2,,m$\mathit{j}=1,2,\dots ,{\mathbf{m}}$.
4:     isx(m) – int64int32nag_int array
m, the dimension of the array, must satisfy the constraint m1${\mathbf{m}}\ge 1$.
Indicates which independent variables are to be included in the model.
If isx(j) > 0${\mathbf{isx}}\left(j\right)>0$, the variable contained in the j$j$th column of x is included in the regression model.
Constraints:
• isx(j)0${\mathbf{isx}}\left(j\right)\ge 0$, for i = 1,2,,m$\mathit{i}=1,2,\dots ,{\mathbf{m}}$;
• if mean = 'M'${\mathbf{mean}}=\text{'M'}$, exactly ip1${\mathbf{ip}}-1$ values of isx must be > 0$\text{}>0$;
• if mean = 'Z'${\mathbf{mean}}=\text{'Z'}$, exactly ip values of isx must be > 0$\text{}>0$.
5:     ip – int64int32nag_int scalar
The number of independent variables in the model, including the mean or intercept if present.
Constraint: ip > 0${\mathbf{ip}}>0$.
6:     y(n) – double array
n, the dimension of the array, must satisfy the constraint n2${\mathbf{n}}\ge 2$.
y$y$, the dependent variable.
Constraint: y(i)0.0${\mathbf{y}}\left(\mathit{i}\right)\ge 0.0$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.
7:     s – double scalar
The scale parameter for the gamma model, ν1${\nu }^{-1}$.
s = 0.0${\mathbf{s}}=0.0$
The scale parameter is estimated with the function using the formula described in Section [Description].
Constraint: s0.0${\mathbf{s}}\ge 0.0$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array y and the first dimension of the arrays x, v. (An error is raised if these dimensions are not equal.)
n$n$, the number of observations.
Constraint: n2${\mathbf{n}}\ge 2$.
2:     m – int64int32nag_int scalar
Default: The dimension of the array isx and the second dimension of the array x. (An error is raised if these dimensions are not equal.)
m$m$, the total number of independent variables.
Constraint: m1${\mathbf{m}}\ge 1$.
3:     wt( : $:$) – double array
Note: the dimension of the array wt must be at least n${\mathbf{n}}$ if weight = 'W'$\mathit{weight}=\text{'W'}$, and at least 1$1$ otherwise.
If weight = 'W'$\mathit{weight}=\text{'W'}$, wt must contain the weights to be used in the weighted regression. If wt(i) = 0.0${\mathbf{wt}}\left(i\right)=0.0$, the i$i$th observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights.
If weight = 'U'$\mathit{weight}=\text{'U'}$, wt is not referenced and the effective number of observations is n$n$.
Constraint: if weight = 'W'$\mathit{weight}=\text{'W'}$, wt(i)0.0${\mathbf{wt}}\left(\mathit{i}\right)\ge 0.0$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.
4:     a – double scalar
If link = 'E'${\mathbf{link}}=\text{'E'}$, a must contain the power of the exponential.
If link'E'${\mathbf{link}}\ne \text{'E'}$, a is not referenced.
Default: 0$0$
Constraint: if link = 'E'${\mathbf{link}}=\text{'E'}$, a0.0${\mathbf{a}}\ne 0.0$.
5:     v(n,ip + 7${\mathbf{ip}}+7$) – double array
If offset = 'N'$\mathit{offset}=\text{'N'}$, v need not be set.
If offset = 'Y'$\mathit{offset}=\text{'Y'}$, v(i,7)${\mathbf{v}}\left(\mathit{i},7\right)$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$, must contain the offset values oi${o}_{\mathit{i}}$. All other values need not be set.
6:     tol – double scalar
Indicates the accuracy required for the fit of the model.
The iterative weighted least squares procedure is deemed to have converged if the absolute change in deviance between iterations is less than tol × (1.0 + Current Deviance)${\mathbf{tol}}×\left(1.0+\text{Current Deviance}\right)$. This is approximately an absolute precision if the deviance is small and a relative precision if the deviance is large.
If 0.0tol < machine precision then the function will use 10 × machine precision instead.
Default: 0$0$
Constraint: tol0.0${\mathbf{tol}}\ge 0.0$.
7:     maxit – int64int32nag_int scalar
The maximum number of iterations for the iterative weighted least squares.
maxit = 0${\mathbf{maxit}}=0$
A default value of 10$10$ is used.
Default: 10$10$
Constraint: maxit0${\mathbf{maxit}}\ge 0$.
8:     iprint – int64int32nag_int scalar
Indicates if the printing of information on the iterations is required.
iprint0${\mathbf{iprint}}\le 0$
There is no printing.
iprint > 0${\mathbf{iprint}}>0$
Every iprint iteration, the following are printed:
• the deviance;
• the current estimates;
• and if the weighted least squares equations are singular then this is indicated.
When printing occurs the output is directed to the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).
Default: 0$0$
9:     eps – double scalar
The value of eps 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 eps the stricter the criterion for selecting the singular value decomposition.
If 0.0eps < machine precision then the function will use machine precision instead.
Default: 0$0$
Constraint: eps0.0${\mathbf{eps}}\ge 0.0$.

### Input Parameters Omitted from the MATLAB Interface

offset weight ldx ldv wk

### Output Parameters

1:     s – double scalar
If on input s = 0.0${\mathbf{s}}=0.0$, s contains the estimated value of the scale parameter, ν̂1${\stackrel{^}{\nu }}^{-1}$.
If on input s0.0${\mathbf{s}}\ne 0.0$, s is unchanged on exit.
2:     dev – double scalar
The adjusted deviance for the fitted model.
3:     idf – int64int32nag_int scalar
The degrees of freedom asociated with the deviance for the fitted model.
4:     b(ip) – double array
The estimates of the parameters of the generalized linear model, β̂$\stackrel{^}{\beta }$.
If mean = 'M'${\mathbf{mean}}=\text{'M'}$, the first element of b will contain the estimate of the mean parameter and b(i + 1)${\mathbf{b}}\left(i+1\right)$ will contain the coefficient of the variable contained in column j$j$ of x${\mathbf{x}}$, where isx(j)${\mathbf{isx}}\left(j\right)$ is the i$i$th positive value in the array isx.
If mean = 'Z'${\mathbf{mean}}=\text{'Z'}$, b(i)${\mathbf{b}}\left(i\right)$ will contain the coefficient of the variable contained in column j$j$ of x${\mathbf{x}}$, where isx(j)${\mathbf{isx}}\left(j\right)$ is the i$i$th positive value in the array isx.
5:     irank – int64int32nag_int scalar
The rank of the independent variables.
If the model is of full rank then ${\mathbf{irank}}={\mathbf{ip}}$.
If the model is not of full rank then irank is an estimate of the rank of the independent variables. irank is calculated as the number of singular values greater that eps × ${\mathbf{eps}}×\text{}$(largest singular value). It is possible for the SVD to be carried out but for irank to be returned as ip.
6:     se(ip) – double array
The standard errors of the linear parameters.
se(i)${\mathbf{se}}\left(\mathit{i}\right)$ contains the standard error of the parameter estimate in b(i)${\mathbf{b}}\left(\mathit{i}\right)$, for i = 1,2,,ip$\mathit{i}=1,2,\dots ,{\mathbf{ip}}$.
7:     cov(ip × (ip + 1) / 2${\mathbf{ip}}×\left({\mathbf{ip}}+1\right)/2$) – double array
The upper triangular part of the variance-covariance matrix of the ip parameter estimates given in b. They are stored in packed form by column, i.e., the covariance between the parameter estimate given in b(i)${\mathbf{b}}\left(i\right)$ and the parameter estimate given in b(j)${\mathbf{b}}\left(j\right)$, ji$j\ge i$, is stored in cov((j × (j1) / 2 + i))${\mathbf{cov}}\left(\left(j×\left(j-1\right)/2+i\right)\right)$.
8:     v(n,ip + 7${\mathbf{ip}}+7$) – double array
Auxiliary information on the fitted model.
 v(i,1)${\mathbf{v}}\left(i,1\right)$ contains the linear predictor value, ηi${\eta }_{\mathit{i}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,2)${\mathbf{v}}\left(i,2\right)$ contains the fitted value, μ̂i${\stackrel{^}{\mu }}_{\mathit{i}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,3)${\mathbf{v}}\left(i,3\right)$ contains the variance standardization, 1/(τi)$\frac{1}{{\tau }_{\mathit{i}}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,4)${\mathbf{v}}\left(i,4\right)$ contains the square root of the working weight, wi(1/2)${w}_{\mathit{i}}^{\frac{1}{2}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,5)${\mathbf{v}}\left(i,5\right)$ contains the Anscombe residual, ri${r}_{\mathit{i}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,6)${\mathbf{v}}\left(i,6\right)$ contains the leverage, hi${h}_{\mathit{i}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. v(i,7)${\mathbf{v}}\left(i,7\right)$ contains the offset, oi${o}_{\mathit{i}}$, for i = 1,2, … ,n$\mathit{i}=1,2,\dots ,n$. If offset = 'N'$\mathit{offset}=\text{'N'}$, all values will be zero. v(i,j)${\mathbf{v}}\left(i,j\right)$, for j = 8, … ,ip + 7$j=8,\dots ,{\mathbf{ip}}+7$, contains the results of the QR$QR$ decomposition or the singular value decomposition.
If the model is not of full rank, i.e., ${\mathbf{irank}}<{\mathbf{ip}}$, the first ip rows of columns 8$8$ to ip + 7${\mathbf{ip}}+7$ contain the P*${P}^{*}$ matrix.
9:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Note: nag_correg_glm_gamma (g02gd) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 2${\mathbf{n}}<2$, or m < 1${\mathbf{m}}<1$, or ldx < n$\mathit{ldx}<{\mathbf{n}}$, or ldv < n$\mathit{ldv}<{\mathbf{n}}$, or ip < 1${\mathbf{ip}}<1$, or link ≠ 'E','I','L','S'${\mathbf{link}}\ne \text{'E'},\text{'I'},\text{'L'},\text{'S'}$ or 'R', or s < 0.0${\mathbf{s}}<0.0$, or link = 'E'${\mathbf{link}}=\text{'E'}$ and a = 0.0${\mathbf{a}}=0.0$, or mean ≠ 'M'${\mathbf{mean}}\ne \text{'M'}$ or 'Z'$\text{'Z'}$, or weight ≠ 'U'$\mathit{weight}\ne \text{'U'}$ or 'W'$\text{'W'}$, or offset ≠ 'N'$\mathit{offset}\ne \text{'N'}$ or 'Y', or maxit < 0${\mathbf{maxit}}<0$, or tol < 0.0${\mathbf{tol}}<0.0$, or eps < 0.0${\mathbf{eps}}<0.0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, weight = 'W'$\mathit{weight}=\text{'W'}$ and a value of wt < 0.0${\mathbf{wt}}<0.0$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, a value of isx < 0${\mathbf{isx}}<0$, or the value of ip is incompatible with the values of mean and isx, or ip is greater than the effective number of observations.
ifail = 4${\mathbf{ifail}}=4$
 On entry, y(i) < 0.0${\mathbf{y}}\left(i\right)<0.0$ for some i = 1,2, … ,n$i=1,2,\dots ,n$.
ifail = 5${\mathbf{ifail}}=5$
A fitted value is at the boundary, i.e., μ̂ = 0.0$\stackrel{^}{\mu }=0.0$. This may occur if there are small values of y$y$ and the model is not suitable for the data. The model should be reformulated with, perhaps, some observations dropped.
ifail = 6${\mathbf{ifail}}=6$
The singular value decomposition has failed to converge. This is an unlikely error exit.
ifail = 7${\mathbf{ifail}}=7$
The iterative weighted least squares has failed to converge in maxit (or default 10$10$) iterations. The value of maxit could be increased but it may be advantageous to examine the convergence using the iprint option. This may indicate that the convergence is slow because the solution is at a boundary in which case it may be better to reformulate the model.
W ifail = 8${\mathbf{ifail}}=8$
The rank of the model has changed during the weighted least squares iterations. The estimate for β$\beta$ returned may be reasonable, but you should check how the deviance has changed during iterations.
W ifail = 9${\mathbf{ifail}}=9$
The degrees of freedom for error are 0$0$. A saturated model has been fitted.

## Accuracy

The accuracy depends on tol as described in Section [Parameters]. As the adjusted deviance is a function of logμ$\mathrm{log}\mu$, the accuracy of the β̂$\stackrel{^}{\beta }$s will be a function of tol, so tol should be set to a smaller value than the accuracy required for β̂$\stackrel{^}{\beta }$.

None.

## Example

```function nag_correg_glm_gamma_example
mean_p = 'M';
x = [1;
1;
1;
1;
1;
0;
0;
0;
0;
0];
isx = [int64(1)];
ip = int64(2);
y = [1;
0.3;
10.5;
9.7;
10.9;
0.62;
0.12;
0.09;
0.5;
2.14];
s = 0;
[sOut, dev, idf, b, irank, se, covar, vOut, ifail] = ...
nag_correg_glm_gamma(link, mean_p, x, isx, ip, y, s, 'tol', 5e-5)
```
```

sOut =

1.0742

dev =

35.0344

idf =

8

b =

1.4408
-1.2865

irank =

2

se =

0.6678
0.6717

covar =

0.4460
-0.4460
0.4511

vOut =

0.1543    6.4800    0.1543   -6.4800   -1.3909    0.2000         0   14.5726   14.4073
0.1543    6.4800    0.1543   -6.4800   -1.9228    0.2000         0    0.3700    1.5431
0.1543    6.4800    0.1543   -6.4800    0.5236    0.2000         0    0.3700    0.0324
0.1543    6.4800    0.1543   -6.4800    0.4318    0.2000         0    0.3700    0.0324
0.1543    6.4800    0.1543   -6.4800    0.5678    0.2000         0    0.3700    0.0324
1.4408    0.6940    1.4408   -0.6940   -0.1107    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -1.3287    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -1.4815    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -0.3106    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940    1.3665    0.2000         0    0.0396   -0.4391

ifail =

0

```
```function g02gd_example
mean_p = 'M';
x = [1;
1;
1;
1;
1;
0;
0;
0;
0;
0];
isx = [int64(1)];
ip = int64(2);
y = [1;
0.3;
10.5;
9.7;
10.9;
0.62;
0.12;
0.09;
0.5;
2.14];
s = 0;
[sOut, dev, idf, b, irank, se, covar, vOut, ifail] = ...
g02gd(link, mean_p, x, isx, ip, y, s, 'tol', 5e-5)
```
```

sOut =

1.0742

dev =

35.0344

idf =

8

b =

1.4408
-1.2865

irank =

2

se =

0.6678
0.6717

covar =

0.4460
-0.4460
0.4511

vOut =

0.1543    6.4800    0.1543   -6.4800   -1.3909    0.2000         0   14.5726   14.4073
0.1543    6.4800    0.1543   -6.4800   -1.9228    0.2000         0    0.3700    1.5431
0.1543    6.4800    0.1543   -6.4800    0.5236    0.2000         0    0.3700    0.0324
0.1543    6.4800    0.1543   -6.4800    0.4318    0.2000         0    0.3700    0.0324
0.1543    6.4800    0.1543   -6.4800    0.5678    0.2000         0    0.3700    0.0324
1.4408    0.6940    1.4408   -0.6940   -0.1107    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -1.3287    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -1.4815    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940   -0.3106    0.2000         0    0.0396   -0.4391
1.4408    0.6940    1.4408   -0.6940    1.3665    0.2000         0    0.0396   -0.4391

ifail =

0

```