The scale estimator \(S_n\) solves the M-estimating equation
$$\frac{1}{n}\sum_{i=1}^{n}\rho\!\left(\frac{x_i - T_n}{S_n}
\right) = \beta$$
where \(T_n\) is fixed at the sample median, \(\beta = 0.5\), and
\(\rho\) is a smooth rho function defined as the square of the logistic
psi (Rousseeuw & Verboven, 2002, Sec. 4.2):
$$\rho_{\mathrm{log}}(x) = \psi_{\mathrm{log}}^2\!\left(
\frac{x}{c}\right)$$
with the tuning constant \(c = 0.37394112142347236\) chosen so that
$$\int\rho(u)\,d\Phi(u) = 0.5$$
yielding a 50% breakdown point.
Iteration scheme.
The equation is solved by multiplicative iteration (Rousseeuw & Verboven,
2002, Eq. 27):
$$S^{(k+1)} = S^{(k)} \cdot \sqrt{2 \cdot \frac{1}{n}\sum
\psi_{\mathrm{log}}^2\!\left(\frac{x_i - T}{c \cdot
S^{(k)}}\right)}$$
Starting value: \(S^{(0)} = \mathrm{MAD}(x)\).
The logistic psi values are computed via the algebraic identity
\(\psi_{\mathrm{log}}(x) = \tanh(x/2)\).
Decoupled estimation.
Scale is estimated with location held fixed at
\(\mathrm{med}(x)\), following the decoupled approach of
Rousseeuw & Verboven (2002, Sec. 4.2). This avoids the
positive-feedback instability of Huber's Proposal 2 in small samples.
Known location.
When loc is supplied, the observations are centered as
\(x_i - \mu\) and the initial scale is set to
\(1.4826 \cdot \mathrm{med}(|x_i - \mu|)\)
rather than the MAD. This lowers the minimum sample size from 4 to 3
(Rousseeuw & Verboven, 2002, Sec. 5).
Fallback.
When \(n\) is below the minimum for iteration:
if \(\mathrm{MAD}(x) \le\) implbound
(implosion), the function returns adm(x);
otherwise, it returns \(\mathrm{MAD}(x)\).