hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_robustm (g02ha)

Purpose

nag_correg_robustm (g02ha) performs bounded influence regression (MM-estimates). Several standard methods are available.

Syntax

[x, y, theta, sigma, c, rs, wgt, work, ifail] = g02ha(indw, ipsi, isigma, indc, x, y, cpsi, h1, h2, h3, cucv, dchi, theta, sigma, 'n', n, 'm', m, 'tol', tol, 'maxit', maxit, 'nitmon', nitmon)
[x, y, theta, sigma, c, rs, wgt, work, ifail] = nag_correg_robustm(indw, ipsi, isigma, indc, x, y, cpsi, h1, h2, h3, cucv, dchi, theta, sigma, 'n', n, 'm', m, 'tol', tol, 'maxit', maxit, 'nitmon', nitmon)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: nitmon, tol, maxit now optional
.

Description

For the linear regression model
y = Xθ + ε ,
y = Xθ+ε ,
where yy is a vector of length nn of the dependent variable,
XX is a nn by mm matrix of independent variables of column rank kk,
θθ is a vector of length mm of unknown parameters,
and εε is a vector of length nn of unknown errors with var(εi) = σ2var(εi)=σ2,
nag_correg_robustm (g02ha) calculates the M-estimates given by the solution, θ̂θ^, to the equation
n
ψ(ri / (σwi))wixij = 0,  j = 1,2,,m,
i = 1
i=1 n ψ ( ri / (σwi) ) wi xij = 0 ,   j=1,2,,m ,
(1)
where riri is the iith residual, i.e., the iith element of r = yXθ̂r=y-Xθ^,
ψψ is a suitable weight function,
wiwi are suitable weights,
and σσ may be estimated at each iteration by the median absolute deviation of the residuals
σ̂ = medi  [|ri|] / β1
σ^ = medi [|ri|] / β1
or as the solution to
n
χ(ri / (σ̂wi))wi2 = (nk)β2
i = 1
i= 1 n χ ( ri / ( σ ^ wi ) ) wi2 = (n-k) β2
for suitable weight function χχ, where β1β1 and β2β2 are constants, chosen so that the estimator of σσ is asymptotically unbiased if the errors, εiεi, have a Normal distribution. Alternatively σσ may be held at a constant value.
The above describes the Schweppe type regression. If the wiwi are assumed to equal 11 for all ii then Huber type regression is obtained. A third type, due to Mallows, replaces (1) by
n
ψ(ri / σ)wixij = 0,  j = 1,2,,m.
i = 1
i=1 n ψ ( ri / σ ) wi xij = 0 ,   j=1,2,,m .
This may be obtained by use of the transformations
wi * sqrt(wi)
yi * yi sqrt(wi)
xij * xij sqrt(wi), j = 1,2,,m
wi*wi yi*yi wi xij*xij wi, j= 1,2,,m
(see Section 3 of Marazzi (1987a)).
For Huber and Schweppe type regressions, β1β1 is the 75th percentile of the standard Normal distribution. For Mallows type regression β1β1 is the solution to
n
1/nΦ(β1 / sqrt(wi)) = 0.75,
i = 1
1n i=1 n Φ ( β1 / wi ) = 0.75 ,
where ΦΦ is the standard Normal cumulative distribution function (see nag_specfun_cdf_normal (s15ab)).
β2β2 is given by
β2 = χ(z)φ(z)dz
in the Huber case;
n
β2 = 1/nwiχ(z)φ(z)dz
i = 1
in the Mallows case;
n
β2 = 1/nwi2χ(z / wi)φ(z)dz
i = 1
in the Schweppe case;
β2 = - χ(z) ϕ(z) dz in the Huber case; β2 = 1 n i=1 n wi - χ(z) ϕ(z) dz in the Mallows case; β2 = 1n i=1 n wi2 - χ (z/wi) ϕ(z) dz in the Schweppe case;
where φϕ is the standard Normal density, i.e., 1/(sqrt(2π))exp((1/2)x2) .12πexp(-12x2) .
The calculation of the estimates of θθ can be formulated as an iterative weighted least squares problem with a diagonal weight matrix GG given by
Gii =
{ ( ψ (ri / (σwi)) )/( (ri / (σwi)) ) , ri ≠ 0 ψ (0) , ri = 0 ,
Gii = { ψ ( ri / (σwi) ) ( ri / (σwi) ) , ri0 ψ (0) , ri=0 ,
where ψ(t)ψ(t) is the derivative of ψψ at the point tt.
The value of θθ at each iteration is given by the weighted least squares regression of yy on XX. This is carried out by first transforming the yy and XX by
i = yisqrt(Gii)
ij = xijsqrt(Gii), j = 1,2,,m
y~i=yiGii x~ij=xijGii, j=1,2,,m
and then using nag_linsys_real_gen_solve (f04jg). If XX is of full column rank then an orthogonal-triangular (QRQR) decomposition is used; if not, a singular value decomposition is used.
The following functions are available for ψψ and χχ in nag_correg_robustm (g02ha).
(a) Unit Weights
ψ(t) = t ,   χ(t) = (t2)/2 .
ψ(t) = t ,   χ(t) = t22 .
This gives least squares regression.
(b) Huber's Function
ψ(t) = max ( − c,min (c,t)) ,   χ(t) =
{ (t2)/2 , |t| ≤ d (d2)/2 , |t| > d
ψ(t) = max(-c,min(c,t)) ,   χ(t) = { t2 2 , |t|d d2 2 , |t|>d
(c) Hampel's Piecewise Linear Function
ψ h_1 , h_2 , h_3 (t) = − ψ h_1 , h_2 , h_3 ( − t) =
{ t, 0 ≤ t ≤ h1 h1, h1 ≤ t ≤ h2 h1 (h3 − t) / (h3 − h2) , h2 ≤ t ≤ h3 0, h3 < t
ψ h1 , h2 , h3 (t) = - ψ h1 , h2 , h3 (-t) = { t, 0t h1 h1, h1 t h2 h1 ( h3 - t ) / ( h3 - h2 ) , h2 t h3 0, h3<t
χ(t) =
{ (t2)/2 , |t| ≤ d (d2)/2 , |t| > d
χ(t) = { t2 2 , |t|d d2 2 , |t|>d
(d) Andrew's Sine Wave Function
ψ(t) =
{ sint, − π ≤ t ≤ π 0, |t| > π
  χ(t) =
{ (t2)/2 , |t| ≤ d (d2)/2 , |t| > d
ψ(t) = { sint, -πtπ 0, |t|>π χ(t) = { t2 2 , |t|d d2 2 , |t|>d
(e) Tukey's Bi-weight
ψ(t) =
{ t (1 − t2)2 , |t| ≤ 1 0, |t| > 1
  χ(t) =
{ (t2)/2 , |t| ≤ d (d2)/2 , |t| > d
ψ(t) = { t ( 1 - t2 ) 2 , |t| 1 0, |t|> 1 χ(t) = { t2 2 , |t|d d2 2 , |t|>d
where cc, h1h1, h2h2, h3h3, and dd are given constants.
Several schemes for calculating weights have been proposed, see Hampel et al. (1986) and Marazzi (1987a). 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 AA has to be found such that:
n
1/nu(zi2)ziziT = I
i = 1
1n i=1 n u (zi2) zi ziT = I
and
zi = Axi ,
zi = Axi ,
where xixi is a vector of length mm containing the iith row of XX,
AA is an mm by mm lower triangular matrix,
and uu is a suitable function.
The weights are then calculated as
wi = f (zi2)
wi = f (zi2)
for a suitable function ff.
nag_correg_robustm (g02ha) finds AA using the iterative procedure
Ak = (Sk + I) Ak1 ,
Ak = (Sk+I) Ak-1 ,
where Sk = (sjl) Sk = (sjl) ,
sjl =
{ − min [max ( hjl / n , − BL),BL] , j > l − min [max ( (1/2) (hjj / n − 1) , − BD),BD] , j = l
sjl = { - min[max( h jl / n ,-BL),BL] , j>l - min[max( 12 (hjj/n-1) ,-BD),BD] , j=l
and
n
hjl = u(zi2)zijzil
i = 1
hjl = i= 1 n u (zi2) zij zil
and BLBL and BDBD are bounds set at 0.90.9.
Two weights are available in nag_correg_robustm (g02ha):
(i) Krasker–Welsch Weights
u (t) = g1 (c/t) ,
u (t) = g1 (ct) ,
where g1(t) = t2 + (1t2)(2Φ(t)1)2tφ(t)g1(t)=t2+(1-t2)(2Φ(t)-1)-2tϕ(t),
Φ(t)Φ(t) is the standard Normal cumulative distribution function,
φ(t)ϕ(t) is the standard Normal probability density function,
and f(t) = 1/t f(t)= 1t .
These are for use with Schweppe type regression.
(ii) Maronna's Proposed Weights
f(t) = sqrt(u(t)) .
u(t) = { c t2 |t|>c 1 |t|c f(t)=u(t) .
u(t) = { c/(t2) |t| > c 1 |t| ≤ c
These are for use with Mallows type regression.
Finally the asymptotic variance-covariance matrix, CC, of the estimates θθ is calculated.
For Huber type regression
C = fH (XTX)1 σ̂2 ,
C = fH (XTX) -1 σ^2 ,
where
fH = 1/(n − m) ( ∑ i = 1n ψ2 (ri / σ̂) )/(
( n )1/n ∑ ψ((ri)/(σ̂)) i = 1 2
) κ2
fH = 1 n-m i= 1 n ψ2 ( ri / σ ^ ) ( 1n i= 1 n ψ ( ri σ^ ) ) 2 κ2
κ2 = 1 + m/n (1/n ∑ i = 1n
( n )ψ(ri / σ̂) − 1/n ∑ ψ(ri / σ̂) i = 1 2
)/(
( n )1/n ∑ ψ((ri)/(σ̂)) i = 1 2
) .
κ2 = 1 + mn 1n i=1 n ( ψ ( ri / σ^ ) - 1n i=1 n ψ ( ri / σ^ ) ) 2 ( 1n i=1 n ψ ( ri σ^ ) ) 2 .
See Huber (1981) and Marazzi (1987b).
For Mallows and Schweppe type regressions CC is of the form
(σ̂)/n2 S11 S2 S11 ,
σ^n 2 S1-1 S2 S1-1 ,
where S1 = 1/nXTDXS1=1nXTDX and S2 = 1/nXTPXS2=1nXTPX.
DD is a diagonal matrix such that the iith element approximates E(ψ(ri / (σwi)))E(ψ(ri/(σwi))) in the Schweppe case and E(ψ(ri / σ)wi)E(ψ(ri/σ)wi) in the Mallows case.
PP is a diagonal matrix such that the iith element approximates E(ψ2(ri / (σwi))wi2)E(ψ2(ri/(σwi))wi2) in the Schweppe case and E(ψ2(ri / σ)wi2)E(ψ2(ri/σ)wi2) in the Mallows case.
Two approximations are available in nag_correg_robustm (g02ha):
  1. Average over the riri 
    Schweppe Mallows Di = ( 1n j=1 n ψ ( rj σ^ wi ) ) wi Di = ( 1n j=1 n ψ ( rj σ^ ) ) wi Pi = ( 1n j=1 n ψ2 ( rj σ^ wi ) ) wi2 Pi = ( 1n j=1 n ψ2 ( rj σ^ ) ) wi2
    Schweppe Mallows
    Di = ( n )1/n ∑ ψ((rj)/( σ̂ wi )) j = 1 wi 
    Di = ( n )1/n ∑ ψ((rj)/(σ̂)) j = 1 wi
    Pi = ( n )1/n ∑ ψ2((rj)/( σ̂ wi )) j = 1 wi2
    Pi = ( n )1/n ∑ ψ2((rj)/(σ̂)) j = 1 wi2
  2. Replace expected value by observed
    Schweppe Mallows
    Di = ψ ((ri)/( σ̂ wi )) wi Di = ψ ((ri)/(σ̂)) wi
    Pi = ψ2 ((ri)/( σ̂ wi )) wi2 Pi = ψ2 ((ri)/(σ̂)) wi2
    .
    Schweppe Mallows Di = ψ ( ri σ^ wi ) wi Di = ψ ( ri σ ^ ) wi Pi = ψ2 ( ri σ ^ wi ) wi2 Pi = ψ2 ( ri σ ^ ) wi2 .
See Hampel et al. (1986) and Marazzi (1987b).
Note:  there is no explicit provision in the function for a constant term in the regression model. However, the addition of a dummy variable whose value is 1.01.0 for all observations will produce a value of θ̂θ^ corresponding to the usual constant term.
nag_correg_robustm (g02ha) is based on routines in ROBETH; see Marazzi (1987a).

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 (1987a) 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
Marazzi A (1987b) Subroutines for robust and bounded influence regression in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 2 Institut Universitaire de Médecine Sociale et Préventive, Lausanne

Parameters

Compulsory Input Parameters

1:     indw – int64int32nag_int scalar
Specifies the type of regression to be performed.
indw < 0indw<0
Mallows type regression with Maronna's proposed weights.
indw = 0indw=0
Huber type regression.
indw > 0indw>0
Schweppe type regression with Krasker–Welsch weights.
2:     ipsi – int64int32nag_int scalar
Specifies which ψψ function is to be used.
ipsi = 0ipsi=0
ψ(t) = tψ(t)=t, i.e., least squares.
ipsi = 1ipsi=1
Huber's function.
ipsi = 2ipsi=2
Hampel's piecewise linear function.
ipsi = 3ipsi=3
Andrew's sine wave.
ipsi = 4ipsi=4
Tukey's bi-weight.
Constraint: 0ipsi40ipsi4.
3:     isigma – int64int32nag_int scalar
Specifies how σσ is to be estimated.
isigma < 0isigma<0
σσ is estimated by median absolute deviation of residuals.
isigma = 0isigma=0
σσ is held constant at its initial value.
isigma > 0isigma>0
σσ is estimated using the χχ function.
4:     indc – int64int32nag_int scalar
If indw0indw0, indc specifies the approximations used in estimating the covariance matrix of θ̂θ^.
indc = 1indc=1
Averaging over residuals.
indc1indc1
Replacing expected by observed.
indw = 0indw=0
indc is not referenced.
5:     x(ldx,m) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
The values of the XX matrix, i.e., the independent variables. x(i,j)xij must contain the ijijth element of XX, for i = 1,2,,ni=1,2,,n and j = 1,2,,mj=1,2,,m.
If indw < 0indw<0, then during calculations the elements of x will be transformed as described in Section [Description]. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input x and the output x.
6:     y(n) – double array
n, the dimension of the array, must satisfy the constraint n > 1n>1.
The data values of the dependent variable.
y(i)yi must contain the value of yy for the iith observation, for i = 1,2,,ni=1,2,,n.
If indw < 0indw<0, then during calculations the elements of y will be transformed as described in Section [Description]. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input y and the output y.
7:     cpsi – double scalar
If ipsi = 1ipsi=1, cpsi must specify the parameter, cc, of Huber's ψψ function.
If ipsi1ipsi1 on entry, cpsi is not referenced.
Constraint: if cpsi > 0.0cpsi>0.0, ipsi = 1ipsi=1.
8:     h1 – double scalar
9:     h2 – double scalar
10:   h3 – double scalar
If ipsi = 2ipsi=2, h1, h2, and h3 must specify the parameters h1h1, h2h2, and h3h3, of Hampel's piecewise linear ψψ function. h1, h2, and h3 are not referenced if ipsi2ipsi2.
Constraint: if ipsi = 2ipsi=2, 0.0h1h2h30.0h1h2h3 and h3 > 0.0h3>0.0.
11:   cucv – double scalar
If indw < 0indw<0, must specify the value of the constant, cc, of the function uu for Maronna's proposed weights.
If indw > 0indw>0, must specify the value of the function uu for the Krasker–Welsch weights.
If indw = 0indw=0, is not referenced.
Constraints:
12:   dchi – double scalar
dd, the constant of the χχ function. dchi is not referenced if ipsi = 0ipsi=0, or if isigma0isigma0.
Constraint: if ipsi0ipsi0 and isigma > 0isigma>0, dchi > 0.0dchi>0.0.
13:   theta(m) – double array
m, the dimension of the array, must satisfy the constraint 1m < n1m<n.
Starting values of the parameter vector θθ. These may be obtained from least squares regression. Alternatively if isigma < 0isigma<0 and sigma = 1sigma=1 or if isigma > 0isigma>0 and sigma approximately equals the standard deviation of the dependent variable, yy, then theta(i) = 0.0thetai=0.0, for i = 1,2,,mi=1,2,,m may provide reasonable starting values.
14:   sigma – double scalar
A starting value for the estimation of σσ. sigma should be approximately the standard deviation of the residuals from the model evaluated at the value of θθ given by theta on entry.
Constraint: sigma > 0.0sigma>0.0.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array y and the first dimension of the array x. (An error is raised if these dimensions are not equal.)
nn, the number of observations.
Constraint: n > 1n>1.
2:     m – int64int32nag_int scalar
Default: The dimension of the array theta and the second dimension of the array x. (An error is raised if these dimensions are not equal.)
mm, the number of independent variables.
Constraint: 1m < n1m<n.
3:     tol – double scalar
The relative precision for the calculation of AA (if indw0indw0), the estimates of θθ and the estimate of σσ (if isigma0isigma0). Convergence is assumed when the relative change in all elements being considered is less than tol.
If indw < 0indw<0 and isigma < 0isigma<0, tol is also used to determine the precision of β1β1.
It is advisable for tol to be greater than 100 × machine precision100×machine precision.
Default: 5e-55e-5
Constraint: tol > 0.0tol>0.0.
4:     maxit – int64int32nag_int scalar
The maximum number of iterations that should be used in the calculation of AA (if indw0indw0), and of the estimates of θθ and σσ, and of β1β1 (if indw < 0indw<0 and isigma < 0isigma<0).
A value of maxit = 50maxit=50 should be adequate for most uses.
Default: 5050
Constraint: maxit > 0maxit>0.
5:     nitmon – int64int32nag_int scalar
The amount of information that is printed on each iteration.
nitmon = 0nitmon=0
No information is printed.
nitmon0nitmon0
The current estimate of θθ, the change in θθ during the current iteration and the current value of σσ are printed on the first and every abs(nitmon)abs(nitmon) iterations.
Also, if indw0indw0 and nitmon > 0nitmon>0 then information on the iterations to calculate AA is printed. This is the current estimate of AA and the maximum value of SijSij (see Section [Description]).
When printing occurs the output is directed to the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).
Default: 00

Input Parameters Omitted from the MATLAB Interface

ldx ldc

Output Parameters

1:     x(ldx,m) – double array
ldxnldxn.
Unchanged, except as described above.
2:     y(n) – double array
Unchanged, except as described above.
3:     theta(m) – double array
theta(i)thetai contains the M-estimate of θiθi, for i = 1,2,,mi=1,2,,m.
4:     sigma – double scalar
Contains the final estimate of σσ if isigma0isigma0 or the value assigned on entry if isigma = 0isigma=0.
5:     c(ldc,m) – double array
ldcmldcm.
The diagonal elements of c contain the estimated asymptotic standard errors of the estimates of θθ, i.e., c(i,i)cii contains the estimated asymptotic standard error of the estimate contained in theta(i)thetai.
The elements above the diagonal contain the estimated asymptotic correlation between the estimates of θθ, i.e., c(i,j)cij, 1i < jm1i<jm contains the asymptotic correlation between the estimates contained in theta(i)thetai and theta(j)thetaj.
The elements below the diagonal contain the estimated asymptotic covariance between the estimates of θθ, i.e., c(i,j)cij, 1j < im1j<im contains the estimated asymptotic covariance between the estimates contained in theta(i)thetai and theta(j)thetaj.
6:     rs(n) – double array
The residuals from the model evaluated at final value of theta, i.e., rs contains the vector (yXθ̂)(y-Xθ^).
7:     wgt(n) – double array
The vector of weights. wgt(i)wgti contains the weight for the iith observation, for i = 1,2,,ni=1,2,,n.
8:     work(4 × n + m × (n + m)4×n+m×(n+m)) – double array
The following values are assigned to work:
  • work(1) = β1work1=β1 if isigma < 0isigma<0, or work(1) = β2work1=β2 if isigma > 0isigma>0.
  • work(2) = work2= number of iterations used to calculate AA.
  • work(3) = work3= number of iterations used to calculate final estimates of θθ and σσ.
  • work(4) = kwork4=k, the rank of the weighted least squares equations.
The rest of the array is used as workspace.
9:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_correg_robustm (g02ha) 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 = 1ifail=1
On entry,n1n1,
orm < 1m<1,
ornmnm,
orldx < nldx<n,
orldc < mldc<m.
  ifail = 2ifail=2
On entry,ipsi < 0ipsi<0,
oripsi > 4ipsi>4.
  ifail = 3ifail=3
On entry,sigma0.0sigma0.0,
oripsi = 1ipsi=1 and cpsi0.0cpsi0.0,
oripsi = 2ipsi=2 and h1 < 0.0h1<0.0,
oripsi = 2ipsi=2 and h1 > h2h1>h2,
oripsi = 2ipsi=2 and h2 > h3h2>h3,
oripsi = 2ipsi=2 and h1 = h2 = h3 = 0.0h1=h2=h3=0.0,
oripsi0ipsi0 and isigma > 0isigma>0 and dchi0.0dchi0.0,
orindw > 0indw>0 and cucv < sqrt(m)cucv<m,
orindw < 0indw<0 and cucv < mcucv<m.
  ifail = 4ifail=4
On entry,tol0.0tol0.0,
ormaxit0maxit0.
  ifail = 5ifail=5
The number of iterations required to calculate the weights exceeds maxit. (Only if indw0indw0.)
  ifail = 6ifail=6
The number of iterations required to calculate β1β1 exceeds maxit. (Only if indw < 0indw<0 and isigma < 0isigma<0.)
  ifail = 7ifail=7
Either the number of iterations required to calculate θθ and σσ exceeds maxit (note that, in this case work(3) = maxitwork3=maxit on exit), or the iterations to solve the weighted least squares equations failed to converge. The latter is an unlikely error exit.
W ifail = 8ifail=8
The weighted least squares equations are not of full rank.
W ifail = 9ifail=9
If indw = 0indw=0 then (XTX)(XTX) is almost singular.
If indw0indw0 then S1S1 is singular or almost singular. This may be due to too many diagonal elements of the matrix being zero, see Section [Further Comments].
W ifail = 10ifail=10
In calculating the correlation factor for the asymptotic variance-covariance matrix either the value of
n n
1/nψ(ri / σ̂) = 0,   or  κ = 0,   or  ψ2(ri / σ̂) = 0.
i = 1 i = 1
1n i=1 n ψ ( ri / σ^ ) = 0 ,   or   κ = 0 ,   or   i=1 n ψ2 ( ri / σ^ ) = 0 .
See Section [Further Comments]. In this case c is returned as XTXXTX.
(Only if indw = 0indw=0.)
W ifail = 11ifail=11
The estimated variance for an element of θ0θ0.
In this case the diagonal element of c will contain the negative variance and the above diagonal elements in the row and column corresponding to the element will be returned as zero.
This error may be caused by rounding errors or too many of the diagonal elements of PP being zero, where PP is defined in Section [Description]. See Section [Further Comments].
  ifail = 12ifail=12
The degrees of freedom for error, nk0n-k0 (this is an unlikely error exit), or the estimated value of σσ was 00 during an iteration.

Accuracy

The precision of the estimates is determined by tol. As a more stable method is used to calculate the estimates of θθ than is used to calculate the covariance matrix, it is possible for the least squares equations to be of full rank but the (XTX)(XTX) matrix to be too nearly singular to be inverted.

Further Comments

In cases when isigma0isigma0 it is important for the value of sigma to be of a reasonable magnitude. Too small a value may cause too many of the winsorized residuals, i.e., ψ(ri / σ)ψ(ri/σ), to be zero or a value of ψ(ri / σ)ψ(ri/σ), used to estimate the asymptotic covariance matrix, to be zero. This can lead to errors ifail = 8ifail=8 or 99 (if indw0indw0), ifail = 10ifail=10 (if indw = 0indw=0) and ifail = 11ifail=11.
nag_correg_robustm_wts (g02hb), nag_correg_robustm_user (g02hd) and nag_correg_robustm_user_varmat (g02hf) together carry out the same calculations as nag_correg_robustm (g02ha) but for user-supplied functions for ψψ, χχ, ψψ and uu.

Example

function nag_correg_robustm_example
indw = int64(1);
ipsi = int64(2);
isigma = int64(1);
indc = int64(0);
x = [1, -1, -1;
     1, -1, 1;
     1, 1, -1;
     1, 1, 1;
     1, -2, 0;
     1, 0, -2;
     1, 2, 0;
     1, 0, 2];
y = [2.1;
     3.6;
     4.5;
     6.1;
     1.3;
     1.9;
     6.7;
     5.5];
cpsi = 0;
h1 = 1.5;
h2 = 3;
h3 = 4.5;
cucv = 3;
dchi = 1.5;
theta = [0;
     0;
     0];
sigma = 1;
[xOut, yOut, thetaOut, sigmaOut, c, rs, wgt, work, ifail] = ...
     nag_correg_robustm(indw, ipsi, isigma, indc, x, y, cpsi, h1, h2, h3, cucv, dchi, theta, sigma)
 

xOut =

     1    -1    -1
     1    -1     1
     1     1    -1
     1     1     1
     1    -2     0
     1     0    -2
     1     2     0
     1     0     2


yOut =

    2.1000
    3.6000
    4.5000
    6.1000
    1.3000
    1.9000
    6.7000
    5.5000


thetaOut =

    4.0423
    1.3083
    0.7519


sigmaOut =

    0.2026


c =

    0.0384   -0.5299   -0.5929
   -0.0006    0.0272    0.0546
   -0.0007    0.0000    0.0311


rs =

    0.1179
    0.1141
   -0.0987
   -0.0026
   -0.1256
   -0.6385
    0.0410
   -0.0462


wgt =

    0.5783
    0.5783
    0.5783
    0.5783
    0.4603
    0.4603
    0.4603
    0.4603


work =

    0.1848
   10.0000
   14.0000
    3.0000
    1.0000
         0
    1.0000
    1.0000
    0.3388
    0.3171
    0.2374
    0.0002
    0.3845
         0
    0.0410
    0.0519
    1.2308
         0
   -0.3077
         0
    0.6667
         0
   -0.3077
         0
    1.0769
   -1.0000
    1.0000
    1.0000
    0.3388
    0.2169
   -0.0921
   -0.0736
   -0.1618
    0.2163
    0.0135
   -0.0662
   -0.0180
    0.1542
    0.2374
    0.0002
   -0.7689
         0
    0.0820
         0
   -0.3388
    0.3171
   -0.2374
    0.0002
         0
         0
         0
    0.1038
    0.1367
         0
   -0.2371
   -0.7840
         0
         0
         0
         0
         0
         0
         0
         0
         0


ifail =

                    0


function g02ha_example
indw = int64(1);
ipsi = int64(2);
isigma = int64(1);
indc = int64(0);
x = [1, -1, -1;
     1, -1, 1;
     1, 1, -1;
     1, 1, 1;
     1, -2, 0;
     1, 0, -2;
     1, 2, 0;
     1, 0, 2];
y = [2.1;
     3.6;
     4.5;
     6.1;
     1.3;
     1.9;
     6.7;
     5.5];
cpsi = 0;
h1 = 1.5;
h2 = 3;
h3 = 4.5;
cucv = 3;
dchi = 1.5;
theta = [0;
     0;
     0];
sigma = 1;
[xOut, yOut, thetaOut, sigmaOut, c, rs, wgt, work, ifail] = ...
     g02ha(indw, ipsi, isigma, indc, x, y, cpsi, h1, h2, h3, cucv, dchi, theta, sigma)
 

xOut =

     1    -1    -1
     1    -1     1
     1     1    -1
     1     1     1
     1    -2     0
     1     0    -2
     1     2     0
     1     0     2


yOut =

    2.1000
    3.6000
    4.5000
    6.1000
    1.3000
    1.9000
    6.7000
    5.5000


thetaOut =

    4.0423
    1.3083
    0.7519


sigmaOut =

    0.2026


c =

    0.0384   -0.5299   -0.5929
   -0.0006    0.0272    0.0546
   -0.0007    0.0000    0.0311


rs =

    0.1179
    0.1141
   -0.0987
   -0.0026
   -0.1256
   -0.6385
    0.0410
   -0.0462


wgt =

    0.5783
    0.5783
    0.5783
    0.5783
    0.4603
    0.4603
    0.4603
    0.4603


work =

    0.1848
   10.0000
   14.0000
    3.0000
    1.0000
         0
    1.0000
    1.0000
    0.3388
    0.3171
    0.2374
    0.0002
    0.3845
         0
    0.0410
    0.0519
    1.2308
         0
   -0.3077
         0
    0.6667
         0
   -0.3077
         0
    1.0769
   -1.0000
    1.0000
    1.0000
    0.3388
    0.2169
   -0.0921
   -0.0736
   -0.1618
    0.2163
    0.0135
   -0.0662
   -0.0180
    0.1542
    0.2374
    0.0002
   -0.7689
         0
    0.0820
         0
   -0.3388
    0.3171
   -0.2374
    0.0002
         0
         0
         0
    0.1038
    0.1367
         0
   -0.2371
   -0.7840
         0
         0
         0
         0
         0
         0
         0
         0
         0


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013