naginterfaces.library.correg.robustm_​corr_​user_​deriv

naginterfaces.library.correg.robustm_corr_user_deriv(ucv, indm, x, a, theta, bl=0.9, bd=0.9, maxit=150, nitmon=0, tol=5e-05, data=None, io_manager=None)[source]

robustm_corr_user_deriv calculates a robust estimate of the covariance matrix for user-supplied weight functions and their derivatives.

For full information please refer to the NAG Library document for g02hl

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02hlf.html

Parameters
ucvcallable (u, ud, w, wd) = ucv(t, data=None)

must return the values of the functions and and their derivatives for a given value of its argument.

Parameters
tfloat

The argument for which the functions and must be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ufloat

The value of the function at the point .

udfloat

The value of the derivative of the function at the point .

wfloat

The value of the function at the point .

wdfloat

The value of the derivative of the function at the point .

indmint

Indicates which form of the function will be used.

.

.

xfloat, array-like, shape

must contain the th observation on the th variable, for , for .

afloat, array-like, shape

An initial estimate of the lower triangular real matrix . Only the lower triangular elements must be given and these should be stored row-wise in the array.

The diagonal elements must be , and in practice will usually be .

If the magnitudes of the columns of are of the same order, the identity matrix will often provide a suitable initial value for .

If the columns of are of different magnitudes, the diagonal elements of the initial value of should be approximately inversely proportional to the magnitude of the columns of .

thetafloat, array-like, shape

An initial estimate of the location parameter, , for .

In many cases an initial estimate of , for , will be adequate.

Alternatively medians may be used as given by univar.robust_1var_median.

blfloat, optional

The magnitude of the bound for the off-diagonal elements of , .

bdfloat, optional

The magnitude of the bound for the diagonal elements of , .

maxitint, optional

The maximum number of iterations that will be used during the calculation of .

nitmonint, optional

Indicates the amount of information on the iteration that is printed.

The value of , and (see Accuracy) will be printed at the first and every iterations.

No iteration monitoring is printed.

When printing occurs the output is directed to the file object associated with the advisory I/O unit (see FileObjManager).

tolfloat, optional

The relative precision for the final estimates of the covariance matrix. Iteration will stop when maximum (see Accuracy) is less than .

dataarbitrary, optional

User-communication data for callback functions.

io_managerFileObjManager, optional

Manager for I/O in this routine.

Returns
covfloat, ndarray, shape

Contains a robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns (lower triangular stored by rows), is returned in , .

afloat, ndarray, shape

The lower triangular elements of the inverse of the matrix , stored row-wise.

wtfloat, ndarray, shape

contains the weights, , for .

thetafloat, ndarray, shape

Contains the robust estimate of the location parameter, , for .

nitint

The number of iterations performed.

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and the th diagonal element of is .

Constraint: all diagonal elements of must be non-zero.

(errno )

On entry, a variable has a constant value, i.e., all elements in column of are identical.

(errno )

value returned by : .

Constraint: .

(errno )

value returned by : .

Constraint: .

(errno )

Iterations to calculate weights failed to converge.

Warns
NagAlgorithmicWarning
(errno )

The sum is zero. Try either a larger initial estimate of or make and less strict.

(errno )

The sum is zero. Try either a larger initial estimate of or make and less strict.

(errno )

The sum is zero. Try either a larger initial estimate of or make and less strict.

Notes

For a set of observations on variables in a matrix , a robust estimate of the covariance matrix, , and a robust estimate of location, , are given by:

where is a correction factor and is a lower triangular matrix found as the solution to the following equations.

and

where

is a vector of length containing the elements of the th row of ,

is a vector of length ,

is the identity matrix and is the zero matrix,

and

and are suitable functions.

robustm_corr_user_deriv covers two situations:

  1. for all ,

  2. .

The robust covariance matrix may be calculated from a weighted sum of squares and cross-products matrix about using weights . In case (1) a divisor of is used and in case (2) a divisor of is used. If , then the robust covariance matrix can be calculated by scaling each row of by and calculating an unweighted covariance matrix about .

In order to make the estimate asymptotically unbiased under a Normal model a correction factor, , is needed. The value of the correction factor will depend on the functions employed (see Huber (1981) and Marazzi (1987)).

robustm_corr_user_deriv finds using the iterative procedure as given by Huber.

and

where , for , for , is a lower triangular matrix such that:

where

, for

and and are suitable bounds.

robustm_corr_user_deriv is based on routines in ROBETH; see Marazzi (1987).

References

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