naginterfaces.library.correg.robustm_corr_user¶
- naginterfaces.library.correg.robustm_corr_user(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
computes a robust estimate of the covariance matrix for user-supplied weight functions. The derivatives of the weight functions are not required.For full information please refer to the NAG Library document for g02hm
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g02/g02hmf.html
- Parameters
- ucvcallable (u, w) = ucv(t, data=None)
must return the values of the functions and 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 .
- wfloat
The value 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.
- tolfloat, optional
The relative precision for the final estimate 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
A robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns (lower triangular stored by rows), that is 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.
- 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
covers two situations:for all ,
.
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
finds using the iterative procedure as given by Huber; see Huber (1981).and
where , for , for is a lower triangular matrix such that
where
, for
and and are suitable bounds.
The value of may be chosen so that is unbiased if the observations are from a given distribution.
robustm_corr_user
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