Repository navigation
BF: use proper scale into HuberScale estimator instead of stand_mad. - #1355
VirgileFritsch wants to merge 3 commits into
Conversation
MAD stay the default init scale estimator in HuberScale iterations when None is provided.
|
This conflicts with some changes that I made in #1341 The use of mad as starting value is wrong, it should be mad with center=0. Changed in my PR. adding an optional starting value is good. |
|
The changes in terms of results were very small as far as I experienced. This confirms that using the HuberScale update is mainly a theoretical thing that does not have a strong impact in practice (or rather, that as never been shown to have a strong impact...). Except for the "center=0" argument in mad, I could not find any conflict with you PR. |
|
In some of the almost degenerate, almost perfect prediction cases mad or HuberScale with different cutoff value makes a difference. see the second example on the mailing list thread "RLM all combinations" What I haven't figured out yet, is whether HuberScale converges to a unique solution, even with different starting values, especially in the degenerate cases. |
There was a problem hiding this comment.
That's the only point where I have conceptual problems.
wls_results.scale is not a robust estimator, It could be far off if there are large outliers.
I think we should still start with mad, center=0
There was a problem hiding this comment.
I also think it is better to start with a mad. If the initial scale
estimate is to small, the residuals can indeed become large and every
observation be assigned a null weight.
There was a problem hiding this comment.
Actually, I realise from what I just wrote that the danger is to
underestimate the initial scale. If we overestimate it instead, it may take
one iteration more to converge (since the weights will all be 1 at the
first step) but IRLS would still succeed. On the contrary, if the scale is
underestimated, we are in the degenerated case I mentioned before.
I am afraid that if a sufficient number of observations fall on the
regression hyperplane, then mad could be equal to zero (could it?) and then
we are in trouble.
I am sorry, I am a bit tired :)
There was a problem hiding this comment.
that mad can be equal to zero (and even worse when mad without center is equal to zero) was the reason for my PR 1341. Adding center=0 for mad rules out the second case, And I added some special treatment for scale=0.
The problem with overestimating the scale is that redescending norms, loss functions, might end up in a local minimum, that doesn't remove many outliers. Standard recommendation (as far as I have seen) is to start with a robust, high breakdown scale estimate.
There was a problem hiding this comment.
BTW: I edited your comments to remove the previous comments that were left in the reply.
There was a problem hiding this comment.
I will be careful next time I reply by mail. Sorry for that.
There was a problem hiding this comment.
From Huber's "Robust Statistics" book:
"As starting values (\theta^(0), \sigma^(0)), we usually take the ordinary least squares estimate, despite its known poor properties [cf. Andrews et al. (1972), for the simple location case].
Redescending \psi-functions are tricky, especially when the starting values for the iterations are non-robust. Residuals that are accidentally large because of the poor starting parameters then may stay large forever because they exert zero pull. It is therefore preferable to start with a monotone \psi, iterate to death, and then append a few (1 or 2) iterations with the nonmonotone \psi."
There was a problem hiding this comment.
#1354 :) The only quote I kept track of
note the words "usually" and "poor properties" in the first sentence in your quote.
I don't have a counter quote, because I didn't keep track, I'm browsing or reading chapters in several books (skipping allmost all the theoretical parts for influence functions and so on)
From the plot it looks like HuberT and RamseyE are the only not redescending, and RamseyE is (re)descending at infinity.
There was a problem hiding this comment.
Yes, I think we agree on the fact the we could use mad(resid, center=0). I changed this into the PR code.
Alternatively, we can give the choice to the user by using the 'init' keyword argument. I think it was partly created for this kind of purpose, so why not accepting "init='ols'/None/False" for an initialization with OLS scale, and "init='mad'" for an initialization with MAD?
Interestingly, changing the OLS scale for a MAD did not change the results of the tests I performed...
|
@VirgileFritsch background questions: How did you find this? Do you have some examples where you ran into problems with this? Now that you pointed it out, I also think starting from the previous scale during updating is better than always starting from mad. |
|
In my applications, I have thousands of targets and I figure out that I I could not experience a large difference in term of results between both |
|
@josef-pkt merge this or do you want to cherry-pick as part of your other PR? |
|
I guess this can be closed. |
In the IRLS algorithm, Huber's scale update is:
"sigma^{n+1} = 1/n_a * sum(\chi(r_i/s)) * s *_ 2,"
where "s = sigma^{n}".
Actual statsmodels' master branch uses "s = mad(r)" by default instead and there is no possibility to change this. In the literature, mad(r) is sometimes used directly to perform the scale update (I guess for code simplification purpose), but I cannot find any reason why we would use mad(r) in combination with an HuberScale estimator.
For backward compatibility reasons, MAD stay the default init scale estimator in HuberScale iterations when None is provided.