﻿ g02dk Method
g02dk calculates the estimates of the parameters of a general linear regression model for given constraints from the singular value decomposition results.

# Syntax

C#
```public static void g02dk(
int ip,
int iconst,
double[] p,
double[,] c,
double[] b,
int idf,
double[] se,
double[] cov,
out int ifail
)```
Visual Basic
```Public Shared Sub g02dk ( _
ip As Integer, _
iconst As Integer, _
p As Double(), _
c As Double(,), _
b As Double(), _
idf As Integer, _
se As Double(), _
cov As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02dk(
int ip,
int iconst,
array<double>^ p,
array<double,2>^ c,
array<double>^ b,
int idf,
array<double>^ se,
array<double>^ cov,
[OutAttribute] int% ifail
)```
F#
```static member g02dk :
ip : int *
iconst : int *
p : float[] *
c : float[,] *
b : float[] *
idf : int *
se : float[] *
cov : float[] *
ifail : int byref -> unit
```

#### Parameters

ip
Type: System..::..Int32
On entry: $p$, the number of terms in the linear model.
Constraint: ${\mathbf{ip}}\ge 1$.
iconst
Type: System..::..Int32
On entry: the number of constraints to be imposed on the parameters, ${n}_{\mathrm{c}}$.
Constraint: $0<{\mathbf{iconst}}<{\mathbf{ip}}$.
p
Type: array<System..::..Double>[]()[][]
An array of size [${\mathbf{ip}}×{\mathbf{ip}}+2×{\mathbf{ip}}$]
On entry: as returned by g02da and g02dd.
c
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, iconst]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{ip}}$
On entry: the iconst constraints stored by column, i.e., the $i$th constraint is stored in the $i$th column of c.
b
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On entry: the parameter estimates computed by using the singular value decomposition, ${\stackrel{^}{\beta }}_{\text{svd}}$.
On exit: the parameter estimates of the parameters with the constraints imposed, ${\stackrel{^}{\beta }}_{\mathrm{c}}$.
Type: System..::..Double
On entry: the residual sum of squares as returned by g02da or g02dd.
Constraint: ${\mathbf{rss}}>0.0$.
idf
Type: System..::..Int32
On entry: the degrees of freedom associated with the residual sum of squares as returned by g02da or g02dd.
Constraint: ${\mathbf{idf}}>0$.
se
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On exit: the standard error of the parameter estimates in b.
cov
Type: array<System..::..Double>[]()[][]
An array of size [${\mathbf{ip}}×\left({\mathbf{ip}}+1\right)/2$]
On exit: 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 ${\mathbf{b}}\left[i-1\right]$ and the parameter estimate given in ${\mathbf{b}}\left[j-1\right]$, $j\ge i$, is stored in ${\mathbf{cov}}\left[\left(j×\left(j-1\right)/2+i\right)-1\right]$.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

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 g02da or g02dd.
In the case of a model not of full rank the methods use a singular value decomposition (SVD) to find the parameter estimates, ${\stackrel{^}{\beta }}_{\text{svd}}$, and their variance-covariance matrix. Details of the SVD are made available in the form of the matrix ${P}^{*}$:
 $P*=D-1P1TP0T,$
as described by g02da and g02dd.
Alternative solutions can be formed by imposing constraints on the parameters. If there are $p$ parameters and the rank of the model is $k$, then ${n}_{c}=p-k$ constraints will have to be imposed to obtain a unique solution.
Let $C$ be a $p$ by ${n}_{c}$ matrix of constraints, such that
 $CTβ=0$
then the new parameter estimates ${\stackrel{^}{\beta }}_{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 ${\left({C}^{\mathrm{T}}{P}_{0}\right)}^{-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

# Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDC) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{ip}}<1$, or ${\mathbf{iconst}}\le 0$, or ${\mathbf{iconst}}\ge {\mathbf{ip}}$, or ${\mathbf{rss}}\le 0.0$, or ${\mathbf{idf}}\le 0$.
${\mathbf{ifail}}=2$
c does not give a model of full rank.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# 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.

# Parallelism and Performance

None.

g02dk is intended for use in situations in which dummy ($0–1$) 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 method is not intended for situations in which the relationships between the independent variables are only approximate.