# OPTwei

OPTwei computes weight function psi(u)/u for optimal weight function

## Syntax

• w=OPTwei(u,c)example

## Description

 w =OPTwei(u, c) Plot of weight function.

## Examples

expand all

### Plot of weight function.

x=-6:0.1:6;
weiOPT=OPTwei(x,2);
plot(x,weiOPT)
xlabel('x','Interpreter','Latex')
ylabel('$W (x) =\psi(x)/x$','Interpreter','Latex')

## Input Arguments

### u — scaled residuals or Mahalanobis distances. Vector.

n x 1 vector containing residuals or Mahalanobis distances for the n units of the sample

Data Types: single| double

### c — tuning parameters. Scalar.

Scalar greater than 0 which controls the robustness/efficiency of the estimator (beta in regression or mu in the location case ...)

Data Types: single| double

## Output Arguments

### w —Optimal weights associated to the scaled residuals or Mahalanobis distances for the n units of the sample. n -by- 1 vector

Function OPTwei transforms vector u as follows Remark: Yohai and Zamar (1997) showed that the optimal $\rho$ function is optimal in the following highly desirable sense: the final M estimate has a breakdown point of one-half and minimizes the maximum bias under contamination distributions (locally for small fraction of contamination), subject to achieving a desidered nominal asymptotic efficiency when the data are Gaussian.
$\psi(x) =\rho' (x) = \begin{cases} \frac{2.7692 }{c^2} \qquad |x| \leq \frac{2}{3} c \\ -\frac{5.3834 }{c^2} +\frac{43.0672 x^2}{c^4} -\frac{69.9840 x^4}{c^6} +\frac{32.3 x^6}{c^8} \qquad \frac{2}{3} c < |x| \leq c \\ 0 & \; \vert x \vert > c. \end{cases}$