g02hb finds, for a real matrix X of full column rank, a lower triangular matrix A such that ATA-1 is proportional to a robust estimate of the covariance of the variables. g02hb is intended for the calculation of weights of bounded influence regression using g02hd.


public static void g02hb(
	G02..::..G02HB_UCV ucv,
	int n,
	int m,
	double[,] x,
	double[] a,
	double[] z,
	double bl,
	double bd,
	double tol,
	int maxit,
	int nitmon,
	out int nit,
	out int ifail
Visual Basic
Public Shared Sub g02hb ( _
	ucv As G02..::..G02HB_UCV, _
	n As Integer, _
	m As Integer, _
	x As Double(,), _
	a As Double(), _
	z As Double(), _
	bl As Double, _
	bd As Double, _
	tol As Double, _
	maxit As Integer, _
	nitmon As Integer, _
	<OutAttribute> ByRef nit As Integer, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g02hb(
	G02..::..G02HB_UCV^ ucv, 
	int n, 
	int m, 
	array<double,2>^ x, 
	array<double>^ a, 
	array<double>^ z, 
	double bl, 
	double bd, 
	double tol, 
	int maxit, 
	int nitmon, 
	[OutAttribute] int% nit, 
	[OutAttribute] int% ifail
static member g02hb : 
        ucv : G02..::..G02HB_UCV * 
        n : int * 
        m : int * 
        x : float[,] * 
        a : float[] * 
        z : float[] * 
        bl : float * 
        bd : float * 
        tol : float * 
        maxit : int * 
        nitmon : int * 
        nit : int byref * 
        ifail : int byref -> unit 


Type: NagLibrary..::..G02..::..G02HB_UCV
ucv must return the value of the function u for a given value of its argument. The value of u must be non-negative.

A delegate of type G02HB_UCV.

Type: System..::..Int32
On entry: n, the number of observations.
Constraint: n>1.
Type: System..::..Int32
On entry: m, the number of independent variables.
Constraint: 1mn.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, m]
Note: dim1 must satisfy the constraint: dim1n
On entry: the real matrix X, i.e., the independent variables. x[i-1,j-1] must contain the ijth element of x, for i=1,2,,n and j=1,2,,m.
Type: array<System..::..Double>[]()[][]
An array of size [m×m+1/2]
On entry: an initial estimate of the lower triangular real matrix A. Only the lower triangular elements must be given and these should be stored row-wise in the array.
The diagonal elements must be 0, although in practice will usually be >0. If the magnitudes of the columns of X are of the same order the identity matrix will often provide a suitable initial value for A. If the columns of X are of different magnitudes, the diagonal elements of the initial value of A should be approximately inversely proportional to the magnitude of the columns of X.
On exit: the lower triangular elements of the matrix A, stored row-wise.
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: the value zi2, for i=1,2,,n.
Type: System..::..Double
On entry: the magnitude of the bound for the off-diagonal elements of Sk.
Suggested value: bl=0.9.
Constraint: bl>0.0.
Type: System..::..Double
On entry: the magnitude of the bound for the diagonal elements of Sk.
Suggested value: bd=0.9.
Constraint: bd>0.0.
Type: System..::..Double
On entry: the relative precision for the final value of A. Iteration will stop when the maximum value of sjl is less than tol.
Constraint: tol>0.0.
Type: System..::..Int32
On entry: the maximum number of iterations that will be used during the calculation of A.
A value of maxit=50 will often be adequate.
Constraint: maxit>0.
Type: System..::..Int32
On entry: determines the amount of information that is printed on each iteration.
The value of A and the maximum value of sjl will be printed at the first and every nitmon iterations.
No iteration monitoring is printed.
When printing occurs the output is directed to the current advisory message unit (see (X04ABF not in this release)).
Type: System..::..Int32%
On exit: the number of iterations performed.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


In fitting the linear regression model
where y is a vector of length n of the dependent variable,
X is an n by m matrix of independent variables,
θ is a vector of length m of unknown parameters,
and ε is a vector of length n of unknown errors,
it may be desirable to bound the influence of rows of the X matrix. This can be achieved by calculating a weight for each observation. Several schemes for calculating weights have been proposed (see Hampel et al. (1986) and Marazzi (1987)). As the different independent variables may be measured on different scales one group of proposed weights aims to bound a standardized measure of influence. To obtain such weights the matrix A has to be found such that
1ni=1nuzi2ziziT=I​  I​ is the identity matrix
where xi is a vector of length m containing the elements of the ith row of X,
A is an m by m lower triangular matrix,
zi is a vector of length m,
and u is a suitable function.
The weights for use with g02hd may then be computed using
for a suitable user-supplied function f.
g02hb finds A using the iterative procedure
where Sk=sjl, for j=1,2,,m and l=1,2,,m, is a lower triangular matrix such that
  • sjl=-minmaxhjl/n,-BL,BL,j>l-minmax12hjj/n-1,-BD,BD,j=l
  • hjl=i=1nuzi2zijzil
and BD and BL are suitable bounds.
In addition the values of zi2, for i=1,2,,n, are calculated.
g02hb is based on routines in ROBETH; see Marazzi (1987).


Hampel F R, Ronchetti E M, Rousseeuw P J and Stahel W A (1986) Robust Statistics. The Approach Based on Influence Functions Wiley
Huber P J (1981) Robust Statistics Wiley
Marazzi A (1987) Weights for bounded influence regression in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 3 Institut Universitaire de Médecine Sociale et Préventive, Lausanne

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry,n1,
On entry,tol0.0,
ordiagonal element of a=0.0,
Value returned by ucv<0.
The method has failed to converge in maxit iterations.
An error occured, see message report.
Invalid Parameters value
Invalid dimension for array value
Negative dimension for array value
Invalid Parameters value


On successful exit the accuracy of the results is related to the value of tol; see [Parameters].

Parallelism and Performance


Further Comments

The existence of A will depend upon the function u; (see Hampel et al. (1986) and Marazzi (1987)), also if X is not of full rank a value of A will not be found. If the columns of X are almost linearly related then convergence will be slow.


This example reads in a matrix of real numbers and computes the Krasker–Welsch weights (see Marazzi (1987)). The matrix A and the weights are then printed.

Example program (C#): g02hbe.cs

Example program data: g02hbe.d

Example program results: g02hbe.r

See Also