RhoPsiWei finds rho, psi, psi', w functions given bdp, or eff or tuning constant c
 Example of call to RhoPsiWei with 2 input arguments.In this case TB link is invoved with bdp=0.5;
n=20; u=randn(n,1); out=RhoPsiWei(u,1);
 Example of call to RhoPsiWei with bdp prespecified.
n=20; u=randn(n,1); out=RhoPsiWei(u,1,'bdp',0.1);
 Example of call to RhoPsiWei with bdp and rhofunc prespecified.
n=20; u=randn(n,1); rhofunc='PD'; out=RhoPsiWei(u,1,'bdp',0.1,'rhofunc',rhofunc);
 Example of call to RhoPsiWei with eff and rhofunc prespecified.
n=20; u=randn(n,1); rhofunc='OPT'; eff=0.9; out=RhoPsiWei(u,1,'eff',eff,'rhofunc',rhofunc);
 Example of call to RhoPsiWei with c prespecified.
n=20; u=randn(n,1); rhofunc='HA'; c=1.5; out=RhoPsiWei(u,1,'c',c,'rhofunc',rhofunc);
 Example of call to RhoPsiWei with c prespecified, and personalized input parameters for HA link.
n=20; u=randn(n,1); rhofunc='HA'; rhofuncparam=[2 3 8]; eff=.95; c=0.5; out=RhoPsiWei(u,1,'eff',eff,'rhofunc',rhofunc,'rhofuncparam',rhofuncparam);
 Example of call to RhoPsiWei with eff prespecified, and personalized input parameters fpr HYP link.
n=20;
u=-4:0.01:4;
rhofunc='HYP';
k=4.2;
eff=0.9;
out=RhoPsiWei(u,1,'eff',eff,'rhofunc',rhofunc,'rhofuncparam',k);
subplot(2,3,1)
plot(u,out.rho)
title('HYP: rho function')
subplot(2,3,2)
plot(u,out.psi)
title('HYP: psi function')
subplot(2,3,3)
plot(u,out.psider)
title('HYP: derivative of  psi function')
subplot(2,3,4)
plot(u,out.psider)
title('HYP: psi(x)*x function')
subplot(2,3,5)
plot(u,out.wei)
title('HYP: weight function')
 
 Example of calling RhoPsiWei with all parameters related to the constant: c, k, A, B and d
     First call RhoPsiWei with efficiency fixed and then use the
       calculated constant for a second call - it will be much faster
    n=20;
    u=-4:0.n=20; u=-4:0.01:4; rhofunc='HYP'; k=4.2; eff=0.9; out=RhoPsiWei(u,1,'eff',eff,'rhofunc',rhofunc,'rhofuncparam',k); out1=RhoPsiWei(u,1,'c',out.c1(1),'rhofunc',rhofunc,'rhofuncparam',out.c1(2:5)); isequal(out.rho, out1.rho) isequal(out.psi, out1.psi) [bdp1, eff1]=HYPc(out.c1(1), 1, 'k', out.c1(2), 'param', out.c1(3:5)); isequal(out.bdp, bdp1) isequal(out.eff, eff1)
ans = logical 1 ans = logical 1 ans = logical 1 ans = logical 0
In this case, given that it is possible to supply just one between bdp, eff and c the call throws an error
n=20;
u=-4:0.01:4;
rhofunc='HYP';
k=4.2;
eff=0.85;
try
out=RhoPsiWei(u,1,'bdp',0.2,'eff',eff,'rhofunc',rhofunc,'rhofuncparam',k);
catch
disp('Only a value among bdp, eff and c must be supplied')
endn=20; u=randn(n,1); rhofunc='PD'; eff=0.9; out=RhoPsiWei([],1,'eff',eff,'rhofunc',rhofunc);
u — scaled residuals or Mahalanobis distances.  
 Vector.Vector containing residuals or Mahalanobis distances for the n units of the sample. If u is empty fields rho, wei, psi, psix and psider of output structure out will be empty.
 Data Types: single|double
v — number of response variables.  
 Scalar.e.g. in regression v=1. So far v can be set to a value greater than 1 just for TB and OPT functions
 Data Types: single|double|int32|int64
Specify optional comma-separated pairs of Name,Value arguments.
 Name is the argument name and Value
 is the corresponding value. Name must appear 
 inside single quotes (' '). 
 You can specify several name and value pair arguments in any order as  
 Name1,Value1,...,NameN,ValueN.
 'bdp',0.2
, 'c',3
, 'eff',0.9
, 'rhofunc','optimal'
, 'rhofuncparam',5
bdp 
—breakdown point.scalar.Scalar defining breakdown point (i.e a number between 0 and 0.5). If none of the optional input arguments c, bdp and eff, are not specified bdp is set to 0.5. Note that if c or eff are specified bdp is automatically found.
       Example:  'bdp',0.2
Data Types: single|double
c 
—tuning constant.scalar.Scalar defining the tuning constant which determines bdp or eff. c corresponds to alpha for mdpd link. Note that if bdp or eff are specified c is automatically found.
       Example:  'c',3
Data Types: single|double
eff 
—asymptotic efficiency.scalar.Scalar defining requested asymptotic efficiency of the estimate (in general a number in the range 0.5 0.99.
Typical values of eff are 0.85, 0.90 or 0.95.
Note that if bdp or c are specified eff is automatically found.
       Example:  'eff',0.9
Data Types: single|double
rhofunc 
—link function.string.String which specifies the rho function which must be used.
Possible values are 'TB' or ''biweight', 'OPT' or 'optimal', 'HYP' or 'hyperbolic';
'HA' or 'hampel', 'PD' or 'mdpd', 'HU' or 'huber', 'AS'.
'biweight' uses Tukey's $\rho$ and $\psi$ functions.
See TBrho and TBpsi.
'optimal' uses optimal $\rho$ and $\psi$ functions.
See OPTrho and OPTpsi.
'hyperbolic' uses hyperbolic $\rho$ and $\psi$ functions.
See HYPrho and HYPpsi.
'hampel' uses Hampel $\rho$ and $\psi$ functions.
See HArho and HApsi.
'mdpd' uses Minimum Density Power Divergence $\rho$ and $\psi$ functions.
'hu' uses Hampel $\rho$ and $\psi$ functions.
See HArho and HApsi.
'AS' uses Andrew's sine $\rho$ and $\psi$ functions.
The default is bisquare
       Example:  'rhofunc','optimal'
Data Types: character
rhofuncparam 
—Additional parameters for the specified rho function.scalar | vector.For hyperbolic rho function it is possible to set up the value of k = sup CVC (the default value of k is 4.5).
For Hampel rho function it is possible to define parameters a, b and c (the default values are a=2, b=4, c=8). For Hyperbolic link function it is possible to pass either one parameter, k (default is k=4.5) or four parameters: k, A, B and d.
       Example:  'rhofuncparam',5
Data Types: single | double
out — description
StructureStructure which contains the following fields
| Value | Description | 
|---|---|
rho | 
 vector of length n which contains the rho function associated to the residuals or Mahalanobis distances for the n units of the sample. This field is empty if input u is empty.  | 
psi | 
 vector of length n which contains the psi function associated to the residuals or Mahalanobis distances for the n units of the sample. This field is empty if input u is empty.  | 
psider | 
 vector of length n which contains the derivative of the psi function associated to the residuals or Mahalanobis distances for the n units of the sample. This field is empty if input u is empty.  | 
wei | 
 vector of length n which contains the weights associated to the residuals or Mahalanobis distances for the n units of the sample. This field is empty if input u is empty.  | 
psix | 
 vector of length n which contains the psi function mutiplied by u associated to the residuals or Mahalanobis distances for the n units of the sample. This field is empty if input u is empty.  | 
class | 
 Character which specifies the link function which has be used. Possible values are 'bisquare', 'optimal', 'hyperbolic'; 'hampel', 'huber' or 'mdpd'.  | 
bdp | 
 scalar which contains the bdp which has been used.  | 
eff | 
 scalar which contains the eff which has been used.  | 
c1 | 
 consistency factor (and other parameters) associated to required breakdown point or nominal efficiency. More precisely, out.c1(1) contains consistency factor c associated to required breakdown point or nominal efficiency out.c1(2:end) contain other parameters associated with the rho (psi) function. For example, if rhofunc='hampel', c1(2:4) must contain parameters (a, b and c) of Hampel rho function. If rhofunc is hyperbolic out.c1(1) specifies the value of the tuning constant c (scalar greater than 0 which controls the robustness/efficiency of the estimator) out.c1(2) contains the prefixed value k (sup of the change-of-variance sensitivity) and out.c1(3:5) contain parameters A, B and d.  | 
kc1 | 
 Expectation of rho associated with out.c1(1) to get a consistent estimator at the model distribution kc1=E(rho)=sup(rho)*bdp  | 
Maronna, R.A., Martin D. and Yohai V.J. (2006), "Robust Statistics, Theory and Methods", Wiley, New York.