G07DCF (PDF version)
G07 Chapter Contents
G07 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G07DCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G07DCF computes an M-estimate of location with (optional) simultaneous estimation of scale, where you provide the weight functions.

2  Specification

SUBROUTINE G07DCF ( CHI, PSI, ISIGMA, N, X, BETA, THETA, SIGMA, MAXIT, TOL, RS, NIT, WRK, IFAIL)
INTEGER  ISIGMA, N, MAXIT, NIT, IFAIL
REAL (KIND=nag_wp)  CHI, PSI, X(N), BETA, THETA, SIGMA, TOL, RS(N), WRK(N)
EXTERNAL  CHI, PSI

3  Description

The data consists of a sample of size n, denoted by x1,x2,,xn, drawn from a random variable X.
The xi are assumed to be independent with an unknown distribution function of the form,
Fxi-θ/σ
where θ is a location parameter, and σ is a scale parameter. M-estimators of θ and σ are given by the solution to the following system of equations;
i=1nψxi-θ^/σ^ = 0 i=1nχxi-θ^/σ^ = n-1β
where ψ and χ are user-supplied weight functions, and β is a constant. Optionally the second equation can be omitted and the first equation is solved for θ^ using an assigned value of σ=σc.
The constant β should be chosen so that σ^ is an unbiased estimator when xi, for i=1,2,,n has a Normal distribution. To achieve this the value of β is calculated as:
β=Eχ=-χz12πexp-z22dz
The values of ψ xi-θ^σ^ σ^ are known as the Winsorized residuals.
The equations are solved by a simple iterative procedure, suggested by Huber:
σ^k=1βn-1 i=1nχ xi-θ^k-1σ^k-1 σ^k-12
and
θ^k=θ^k- 1+1n i= 1nψ xi-θ^k- 1σ^k σ^k
or
σ^k=σc
if σ is fixed.
The initial values for θ^ and σ^ may be user-supplied or calculated within G07DBF as the sample median and an estimate of σ based on the median absolute deviation respectively.
G07DCF is based upon subroutine LYHALG within the ROBETH library, see Marazzi (1987).

4  References

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) Subroutines for robust estimation of location and scale in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 1 Institut Universitaire de Médecine Sociale et Préventive, Lausanne

5  Parameters

1:     CHI – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
CHI must return the value of the weight function χ for a given value of its argument. The value of χ must be non-negative.
The specification of CHI is:
FUNCTION CHI ( T)
REAL (KIND=nag_wp) CHI
REAL (KIND=nag_wp)  T
1:     T – REAL (KIND=nag_wp)Input
On entry: the argument for which CHI must be evaluated.
CHI must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which G07DCF is called. Parameters denoted as Input must not be changed by this procedure.
2:     PSI – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
PSI must return the value of the weight function ψ for a given value of its argument.
The specification of PSI is:
FUNCTION PSI ( T)
REAL (KIND=nag_wp) PSI
REAL (KIND=nag_wp)  T
1:     T – REAL (KIND=nag_wp)Input
On entry: the argument for which PSI must be evaluated.
PSI must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which G07DCF is called. Parameters denoted as Input must not be changed by this procedure.
3:     ISIGMA – INTEGERInput
On entry: the value assigned to ISIGMA determines whether σ^ is to be simultaneously estimated.
ISIGMA=0
The estimation of σ^ is bypassed and SIGMA is set equal to σc.
ISIGMA=1
σ^ is estimated simultaneously.
4:     N – INTEGERInput
On entry: n, the number of observations.
Constraint: N>1.
5:     X(N) – REAL (KIND=nag_wp) arrayInput
On entry: the vector of observations, x1,x2,,xn.
6:     BETA – REAL (KIND=nag_wp)Input
On entry: the value of the constant β of the chosen CHI function.
Constraint: BETA>0.0.
7:     THETA – REAL (KIND=nag_wp)Input/Output
On entry: if SIGMA>0, then THETA must be set to the required starting value of the estimate of the location parameter θ^. A reasonable initial value for θ^ will often be the sample mean or median.
On exit: the M-estimate of the location parameter θ^.
8:     SIGMA – REAL (KIND=nag_wp)Input/Output
On entry: the role of SIGMA depends on the value assigned to ISIGMA as follows.
If ISIGMA=1, SIGMA must be assigned a value which determines the values of the starting points for the calculation of θ^ and σ^. If SIGMA0.0, then G07DCF will determine the starting points of θ^ and σ^. Otherwise, the value assigned to SIGMA will be taken as the starting point for σ^, and THETA must be assigned a relevant value before entry, see above.
If ISIGMA=0, SIGMA must be assigned a value which determines the values of σc, which is held fixed during the iterations, and the starting value for the calculation of θ^. If SIGMA0, then G07DCF will determine the value of σc as the median absolute deviation adjusted to reduce bias (see G07DAF) and the starting point for θ. Otherwise, the value assigned to SIGMA will be taken as the value of σc and THETA must be assigned a relevant value before entry, see above.
On exit: the M-estimate of the scale parameter σ^, if ISIGMA was assigned the value 1 on entry, otherwise SIGMA will contain the initial fixed value σc.
9:     MAXIT – INTEGERInput
On entry: the maximum number of iterations that should be used during the estimation.
Suggested value: MAXIT=50.
Constraint: MAXIT>0.
10:   TOL – REAL (KIND=nag_wp)Input
On entry: the relative precision for the final estimates. Convergence is assumed when the increments for THETA, and SIGMA are less than TOL×max1.0,σk-1.
Constraint: TOL>0.0.
11:   RS(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the Winsorized residuals.
12:   NIT – INTEGEROutput
On exit: the number of iterations that were used during the estimation.
13:   WRK(N) – REAL (KIND=nag_wp) arrayOutput
On exit: if SIGMA0.0 on entry, WRK will contain the n observations in ascending order.
14:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,N1,
orMAXIT0,
orTOL0.0,
orISIGMA0 or 1.
IFAIL=2
On entry,BETA0.0.
IFAIL=3
On entry,all elements of the input array X are equal.
IFAIL=4
SIGMA, the current estimate of σ, is zero or negative. This error exit is very unlikely, although it may be caused by too large an initial value of SIGMA.
IFAIL=5
The number of iterations required exceeds MAXIT.
IFAIL=6
On completion of the iterations, the Winsorized residuals were all zero. This may occur when using the ISIGMA=0 option with a redescending ψ function, i.e., ψ=0 if t>τ, for some positive constant τ.
If the given value of σ is too small, then the standardized residuals xi-θ^kσc , will be large and all the residuals may fall into the region for which ψt=0. This may incorrectly terminate the iterations thus making THETA and SIGMA invalid.
Re-enter the routine with a larger value of σc or with ISIGMA=1.
IFAIL=7
The value returned by the CHI function is negative.

7  Accuracy

On successful exit the accuracy of the results is related to the value of TOL, see Section 5.

8  Further Comments

Standard forms of the functions ψ and χ are given in Hampel et al. (1986), Huber (1981) and Marazzi (1987). G07DBF calculates M-estimates using some standard forms for ψ and χ.
When you supply the initial values, care has to be taken over the choice of the initial value of σ. If too small a value is chosen then initial values of the standardized residuals xi-θ^kσ  will be large. If the redescending ψ functions are used, i.e., ψ=0 if t>τ, for some positive constant τ, then these large values are Winsorized as zero. If a sufficient number of the residuals fall into this category then a false solution may be returned, see page 152 of Hampel et al. (1986).

9  Example

The following program reads in a set of data consisting of eleven observations of a variable X.
The PSI and CHI functions used are Hampel's Piecewise Linear Function and Hubers CHI function respectively.
Using the following starting values various estimates of θ and σ are calculated and printed along with the number of iterations used:
(a) G07DCF determined the starting values, σ is estimated simultaneously.
(b) You must supply the starting values, σ is estimated simultaneously.
(c) G07DCF determined the starting values, σ is fixed.
(d) You must supply the starting values, σ is fixed.

9.1  Program Text

Program Text (g07dcfe.f90)

9.2  Program Data

Program Data (g07dcfe.d)

9.3  Program Results

Program Results (g07dcfe.r)


G07DCF (PDF version)
G07 Chapter Contents
G07 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012