You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: incorrect calculation of the last piecewise element of Hampel.rho + missing source of equations #8697
The formula for the last piecewise element of Hampel.rho is incorrect. It is said in the docstring to be: rho(z) = a*(b + c - a) for \|z\| > c
while it should be rho(z) = a/2*(b + c - a) for \|z\| > c
I took the correct equation from corresponding R package robustbase, see their vignette psi_functions Section 2.2 on page 5.
They present standardized $\tilde{\rho}$ instead of $\rho$, while statsmodels presents $\rho$, but is only a matter of multiplying $\rho$ by $\tilde{\rho}$ to get the representation from statsmodels and see the difference in the formulae.
robustbase points to Hampel et al., 1986 as the source of their calculations, while statsmodels have no reference for the equations.
Code Sample, a copy-pastable example if possible
No code sample as the code is correct with respect to current documentation, it is the documentation (therefore formula) that is incorrect.
Details
Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.
Note: Please be sure you are using the latest released version of statsmodels, or a recent build of main. If your problem has been fixed in an unreleased version, you might be able to use main until a new release occurs.
Note: If you are using a released version, have you verified that the bug exists in the main branch of this repository? It helps the limited resources if we know problems exist in the current main branch so that they do not need to check whether the code sample produces a bug in the next release.
If the issue has not been resolved, please file it in the issue tracker.
Expected Output
A different formula for last piecewise element in Hampel.rho:
rho(z) = a/2*(b + c - a) for \|z\| > c
implemented in the code.
Output of import statsmodels.api as sm; sm.show_versions()
Details
[paste the output of import statsmodels.api as sm; sm.show_versions() here below this line]
I'm fixing hampel and a few cases in other norms in #8801
I did not look at the details here because I already had a fix for hampel rho in an old PR
The unit tests are now against robustbase, but for rho and we don't use standardized rho in statsmodels.
The scaling is so that we get internal consistency across methods in the norms.
I fixed the docstrings but we don't have unit tests for docstrings, so mistakes are still possible.
Activity
kkmita commentedon Feb 21, 2023
Note that this affects the same line of code as in #8696 , but a different problem is present in this issue.
josef-pkt commentedon Apr 16, 2023
I'm fixing hampel and a few cases in other norms in #8801
I did not look at the details here because I already had a fix for hampel rho in an old PR
The unit tests are now against robustbase, but for rho and we don't use standardized rho in statsmodels.
The scaling is so that we get internal consistency across methods in the norms.
I fixed the docstrings but we don't have unit tests for docstrings, so mistakes are still possible.