Repository navigation
nns_meboot: keep the residual scale when the drift changes (book ch20) - #172
Closed
gitRasheed wants to merge 2 commits into
Closed
gitRasheed wants to merge 2 commits into
gitRasheed wants to merge 2 commits into
Conversation
gitRasheed
force-pushed
the
rasheed/book-copula-anchor
branch
from
November 2, 2026 04:12
cf3233e to
dc59d8c
Compare
gitRasheed
force-pushed
the
rasheed/book-meboot-drift
branch
from
November 2, 2026 04:12
71c8967 to
41b0ec5
Compare
Mirrors R's meboot-drift branch (NNS.meboot), including the round-2 corrections. Replicates are a baseline plus resampled residuals (book ch. 20), but three steps measured the residual density against the levels: - expand_sd rescaled every replicate toward sd(x), which includes the original trend. It now runs only when the original slope is kept. - force_clt centred and spread the replicate means on x. With a changed drift it now uses the new baseline plus the original residuals. - scl_adjustment compared the residual density with mean(x) and sd(x) and scaled the levels. kappa now uses the residuals' mean and sd and scales the residuals before the baseline is added. A changed slope (drift=False, target_drift, target_drift_scale) now pivots about mean(x): mean(x) + slope * (t - (n + 1) / 2). The default drift=True path is unchanged. AirPassengers, reps = 100, rho = 1, seed 1, mean over replicates (before -> after; R moves the same way): drift=False sd 122.89 -> 47.31, slope -0.024 -> -0.009 target_drift=1 sd 122.89 -> 62.82, slope 1.938 -> 0.991 target_drift_scale=0.5 sd 122.89 -> 72.57, slope 2.234 -> 1.320 scl_adjustment=True sd 51.55 -> 122.00, slope 1.136 -> 2.688 defaults unchanged (sd 122.05, slope 2.690) The replicate mean stays 280.30 in every case. The stat-summary R helper takes drift and target_drift, only entering the payload when given. New NNS.meboot entries for the new tests.
…aling The drift tests passed with the old force_clt reference (drift=False mean spread 0.270, not 0.0706) and the scale test without the adjustment; all now fail on those mutants.
gitRasheed
force-pushed
the
rasheed/book-copula-anchor
branch
from
November 2, 2026 23:09
dc59d8c to
f01e08b
Compare
gitRasheed
force-pushed
the
rasheed/book-meboot-drift
branch
from
November 2, 2026 23:09
41b0ec5 to
0f32a89
Compare
Contributor
|
Incorporated through NNS R 14.0 integration #192, merged as |
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.
Book ch20 builds replicates as a baseline plus resampled residuals (ch20:193-206), but three steps of
nns_mebootmeasured the residual density against the levels. Withdrift=Falseevery replicate was rescaled toward sd(x), trend included, so AirPassengers replicates kept the full sd of the trending series. We mirror OVVO-Financial/NNS#92, which makes R follow the book, including its round-2 corrections. That PR changes the method, so the R author may close it; if so, this slice should be dropped too.Stacked on #171; merge with a merge commit.
Changes
expand_sdruns only when the original slope is kept.force_cltcentres and spreads the replicate means on the new baseline plus the original residuals instead of on x.scl_adjustmenttakes kappa from the residuals' mean and sd and scales the residuals before the baseline is added.drift=False,target_drift,target_drift_scale) pivots about mean(x): mean(x) + slope * (t - (n + 1) / 2).AirPassengers, reps = 100, rho = 1, seed 1, mean over replicates:
drift=Falsesd goes from 122.89 to 47.31,target_drift=1from 122.89 to 62.82, andscl_adjustment=Truefrom 51.55 to 122.00. The defaultdrift=Truepath is unchanged (sd 122.05), and the replicate mean stays 280.30 in every case.Tests
New parity tests and
NNS.mebootcache entries for the changed-drift andscl_adjustmentcases; the stat-summary R helper takesdriftandtarget_drift. The parity cache encodes R 13.3 plus the fixes in OVVO-Financial/NNS#73-#92. The nineNNS.VARstrict xfails stay until #174.Mirrors OVVO-Financial/NNS#92
Review
GPT-6.1 Sol reviewed this slice and raised one finding, which we took: the new tests still passed with the old force.clt reference and without the scale adjustment. New tests pin the spread of the replicate means (0.0706 expected; the old reference gives 0.270) and check that kappa scales the residuals, not the levels. Each fails on its mutant. The fix commit has not been re-reviewed.