Repository navigation
Add the absolute-increment rule for the Hessian - #7
Merged
Merged
Conversation
ApproximateSD has always sized a single relative increment so that moving every parameter together changes the function by 0.5% of its own value. Colquhoun, Hatton & Hawkes (2003) J Physiol 547:699-728, p. 702, describe a different rule, and it is the one their Tables 2 and 3 were made with: find the increment for each parameter separately that changes the log likelihood by a specified absolute amount, and where no such increment exists, omit that parameter's row and column from the Hessian before inverting it. delta_L selects that rule. The per-parameter part is what matters: sizing one step by moving every parameter together moves along the diagonal ridge that an anisotropic likelihood has, where the function changes slowly, so the step that results is far too large for the directions across the ridge. kept and dropped say which parameters survived; hessian and covariance cover those only, while sd and correlations stay the full size of theta with nan in the dropped places, so sd[i] always refers to theta[i] and a table of results cannot silently misalign. A function that raises where it cannot be evaluated is treated as too large a step rather than propagating the error. The default path is untouched: the existing pinned Hessian, covariance, SD and correlation values are unchanged. 12 new tests, on quadratics whose Hessian is known exactly, so that a failure means the estimator is wrong rather than that a reference value drifted. One of them records that the flat-parameter case is precisely what the default rule cannot do. The suite goes from 36 to 48 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
ApproximateSDhas always sized one relative increment, chosen so that moving every parameter together changes the function by 0.5% of its own value.Colquhoun, Hatton & Hawkes (2003) J Physiol 547:699–728, p. 702, describe a different rule, and it is the one their Tables 2 and 3 were made with: find the increment for each parameter separately that changes the log likelihood by a specified absolute amount, and where no such increment exists, omit that parameter's row and column from the Hessian before inverting it.
delta_Lselects that rule.Why the per-parameter part matters
Sizing one step by moving every parameter at once walks along the diagonal ridge that an anisotropic likelihood has — the direction in which the function barely changes. The step that comes out is therefore far too large for the directions across the ridge, which are the ones the curvature is wanted for.
The interface
keptanddroppedsay which parameters survived.hessianandcovariancecover the survivors only;sdandcorrelationsstay the full size oftheta, withnanin the dropped places.So
sd[i]always refers totheta[i], and a table of results cannot silently misalign — which is the failure mode worth designing against here, because it produces a plausible table rather than an error.A function that raises where it cannot be evaluated is treated as too large a step rather than propagating the error.
The default path is untouched
Verified rather than asserted: the existing pinned Hessian, covariance, SD and correlation values in
test_errors.pyare unchanged, and that file still passes.Tests
10 new, on quadratics whose Hessian is known exactly, so a failure means the estimator is wrong rather than that a reference value drifted:
test_the_flat_case_is_what_the_default_rule_cannot_dorecords the case that motivated the whole thing.Suite goes from 48 to 60 passed.
Provenance
Written on 2 September during the reproduction of CHH 2003, committed to a local
masterand never pushed. This is that work rebased ontoorigin/masteras a single commit, with the merge commit flattened out. Nothing in the module or its tests references the reproduction; it needs no new dependency.🤖 Generated with Claude Code