# HYPpsider

HYPpsider computes derivative of psi function for hyperbolic tangent estimator

## Syntax

• psiHYPder=HYPpsider(u, cktuning)example

## Description

 psiHYPder =HYPpsider(u, cktuning) Plot of derivative of hyperbolic psi function.

## Examples

expand all

### Plot of derivative of hyperbolic psi function.

% Plot of derivative of hyperbolic psi function.
x=-9:0.1:9;
ctuning=6;
ktuning=4.5;
psiHYPder=HYPpsider(x,[ctuning,ktuning]);
plot(x,psiHYPder)
xlabel('x','Interpreter','Latex')
ylabel(' Hyperbolic $\psi''(x)$','Interpreter','Latex')

## Related Examples

expand all

### Comparison among four derivatives of psi function.

TB, Optimal, Hampel, Hyperbolic

bdp=0.5;
c=TBbdp(bdp,1);
subplot(2,2,1)
% 1st panel is Tukey biweight
x=-4:0.01:4;
psiTBder=TBpsider(x,c);
plot(x,psiTBder)
xlabel('x','Interpreter','Latex')
ylabel('$\psi''(x)$','Interpreter','Latex')
title('Tukey biweight')
subplot(2,2,2)
% 2nd panel is optimal
c=OPTbdp(bdp,1);
c=c/3;
% Remark: in this case it is necessary to multiply by 3.25*c^2 because the
% optimal has been standardized in such a way that sup(rho(x))=1
psiOPTder=(3.25*c^2)*OPTpsider(x,c);
plot(x,psiOPTder)
xlim([-4 4])
xlabel('x','Interpreter','Latex')
ylabel('$\psi''(x)$','Interpreter','Latex')
title('Optimal')
subplot(2,2,3)
% 3rd panel is Hampel
% Obtain bottom panel of Figure 11.10 p. 375 of
% Hoaglin et al. (1987)
c=HAbdp(bdp,1);
psiHA=HApsider(x,c);
plot(x,psiHA)
xlabel('x','Interpreter','Latex')
ylabel('$\psi''(x)$','Interpreter','Latex')
title('Hampel')
subplot(2,2,4)
% 4th panel is hyperbolic
% c=HYPbdp(0.5,1);
%ktuning=4.5;
ktuning=4.5;
% Precalculated values
c = 2.010311082005501;
A = 0.008931591866092;
B = 0.051928487236632;
d=  0.132017481327058;
% Alternatively the values can be found using
%[c,A,B,d]=HYPbdp(0.5,1,ktuning);
psiHYPder=HYPpsider(x,[c,ktuning,A,B,d]);
plot(x,psiHYPder)
xlabel('x','Interpreter','Latex')
ylabel('$\psi''(x)$','Interpreter','Latex')
title('Hyperbolic')

## 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

### cktuning — tuning parameters. Vector of length 2 or of length 5.

cktuning specifies the value of the tuning constant c (scalar greater than 0 which controls the robustness/efficiency of the estimator) and the prefixed value k (sup of the change-of-variance sensitivity) and the values of parameters A, B and d.

cktuning(1) = c;

cktuning(2) = k = supCVC(psi,x) x \in R;

cktuning(3)=A;

cktuning(4)=B;

cktuning(5)=d;

Remark - if length(cktuning)==2 values of A, B and d will be computed automatically

Data Types: single| double

## Output Arguments

### psiHYPder —Derivative of psi function.  Vector

n x 1 vector which contains the values of hyperbolic psi'(u) function associated to the residuals or Mahalanobis distances for the n units of the sample.

Function HYPpsi transforms vector u as follows $HYPpsider(u)= \left\{ \begin{array}{cc} 1 & |u| \leq d, \\ 0.5 B (1-k) \left( 1/\cosh \left( \sqrt{(k - 1) B^2/A} (c -|u|)/2 \right)^2 \right) & d \leq |u| < c, \\ 0 & |u| \geq c. \end{array} \right.$ It is necessary to have $0 < A < B < 2 normcdf(c)-1- 2 c normpdf(c) <1$