g02dd calculates the regression parameters for a general linear regression model. It is intended to be called after g02dcg02de or g02df.


public static void g02dd(
	int n,
	int ip,
	double[,] q,
	ref double rss,
	out int idf,
	double[] b,
	double[] se,
	double[] cov,
	out bool svd,
	out int irank,
	double[] p,
	double tol,
	out int ifail
Visual Basic
Public Shared Sub g02dd ( _
	n As Integer, _
	ip As Integer, _
	q As Double(,), _
	ByRef rss As Double, _
	<OutAttribute> ByRef idf As Integer, _
	b As Double(), _
	se As Double(), _
	cov As Double(), _
	<OutAttribute> ByRef svd As Boolean, _
	<OutAttribute> ByRef irank As Integer, _
	p As Double(), _
	tol As Double, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g02dd(
	int n, 
	int ip, 
	array<double,2>^ q, 
	double% rss, 
	[OutAttribute] int% idf, 
	array<double>^ b, 
	array<double>^ se, 
	array<double>^ cov, 
	[OutAttribute] bool% svd, 
	[OutAttribute] int% irank, 
	array<double>^ p, 
	double tol, 
	[OutAttribute] int% ifail
static member g02dd : 
        n : int * 
        ip : int * 
        q : float[,] * 
        rss : float byref * 
        idf : int byref * 
        b : float[] * 
        se : float[] * 
        cov : float[] * 
        svd : bool byref * 
        irank : int byref * 
        p : float[] * 
        tol : float * 
        ifail : int byref -> unit 


Type: System..::..Int32
On entry: the number of observations.
Constraint: n1.
Type: System..::..Int32
On entry: p, the number of terms in the regression model.
Constraint: ip1.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, ip+1]
Note: dim1 must satisfy the constraint:
  • if rss0.0, dim1n;
  • otherwise dim1ip.
On entry: must be the array q as output by g02dc g02de g02df (G02EEF not in this release). If on entry rss0.0 then all n elements of c are needed. This is provided by methods g02de g02df (G02EEF not in this release).
Type: System..::..Double%
On entry: either the residual sum of squares or a value less than or equal to 0.0 to indicate that the residual sum of squares is to be calculated by the method.
On exit: if rss0.0 on entry, then on exit rss will contain the residual sum of squares as calculated by g02dd.
If rss was positive on entry, it will be unchanged.
Type: System..::..Int32%
On exit: the degrees of freedom associated with the residual sum of squares.
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On exit: the estimates of the p parameters, β^.
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On exit: the standard errors of the p parameters given in b.
Type: array<System..::..Double>[]()[][]
An array of size [ip×ip+1/2]
On exit: the upper triangular part of the variance-covariance matrix of the p parameter estimates given in b. They are stored packed by column, i.e., the covariance between the parameter estimate given in b[i-1] and the parameter estimate given in b[j-1], ji, is stored in cov[j×j-1/2+i-1].
Type: System..::..Boolean%
On exit: if a singular value decomposition has been performed, svd=true, otherwise svd=false.
Type: System..::..Int32%
On exit: the rank of the independent variables.
If svd=false, irank=ip.
If svd=true, irank is an estimate of the rank of the independent variables.
irank is calculated as the number of singular values greater than tol× (largest singular value). It is possible for the SVD to be carried out but irank to be returned as ip.
Type: array<System..::..Double>[]()[][]
An array of size [ip×ip+2×ip]
On exit: contains details of the singular value decomposition if used.
If svd=false, p is not referenced.
If svd=true, the first ip elements of p will not be referenced, the next ip values contain the singular values. The following ip×ip values contain the matrix P* stored by columns.
Type: System..::..Double
On entry: 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.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.
Suggested value: tol=0.000001.
Constraint: tol0.0.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


A general linear regression model fitted by g02da may be adjusted by adding or deleting an observation using g02dc, adding a new independent variable using g02de or deleting an existing independent variable using g02df. Alternatively a model may be constructed by a forward selection procedure using (G02EEF not in this release). These methods compute the vector c and the upper triangular matrix R. g02dd takes these basic results and computes the regression coefficients, β^, their standard errors and their variance-covariance matrix.
If R is of full rank, then β^ is the solution to
where c1 is the first p elements of c.
If R is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of R,
where D is a k by k diagonal matrix with nonzero diagonal elements, k being the rank of R, and Q* and P are p by p orthogonal matrices. This gives the solution
P1 being the first k columns of P, i.e., P=P1P0, and Q*1 being the first k columns of Q*.
Details of the SVD are made available in the form of the matrix P*:
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 g02dk after calling g02dd. Only certain linear combinations of the parameters will have unique estimates; these are known as estimable functions. These can be estimated using 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 c for the whole sample is provided.


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 (LDQ) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry,n<1,
The degrees of freedom for error are less than or equal to 0. In this case the estimates of β are returned but not the standard errors or covariances.
The singular value decomposition, if used, has failed to converge, see (F02WUF not in this release). This is an unlikely error exit.
An error occured, see message report.
Invalid Parameters value
Invalid dimension for array value
Negative dimension for array value
Invalid Parameters value


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

Parallelism and Performance


Further Comments



See Also