Repository navigation
Conversation
Add LocalBlockBootstrap(block_size, locality, *args, seed=None, **kwargs), the local block bootstrap of Paparoditis and Politis (2002) for series whose properties change slowly. Block m starts at an integer drawn uniformly from [max(0, m * block_size - locality), min(n - block_size, m * block_size + locality)] and the blocks are truncated to n observations. The locality is an integer number of observations so that clone works with data of any length. The class subclasses CircularBlockBootstrap for the block_size property, str and repr, and adds a read-only locality, clone that keeps both parameters, and a vectorised update_indices. It is not an option of SPA, StepM or MCS. xref #617
Check the block starts against loop implementations of the algorithm of the paper (in Python and in R) driven by the same uniform draws, the exact support of the starts in edge cases, the uniformity and independence of the starts, the standard error of the mean of a trend plus noise, seed, state, reset and clone, and apply, cov, var and every conf_int method against a replay of the reference. Table-driven validation rows cover locality, block_size, seed, the data and the method arguments. xref #617
| checked = check_int("locality", locality, lower=0) | ||
| super().__init__(block_size, *args, seed=seed, **kwargs) | ||
| self._locality: int = checked | ||
| self._parameters = [self._block_size, checked] |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #967 +/- ##
==========================================
+ Coverage 98.95% 98.97% +0.02%
==========================================
Files 136 138 +2
Lines 30043 30713 +670
Branches 2331 2375 +44
==========================================
+ Hits 29729 30399 +670
Misses 256 256
Partials 58 58
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Target 9.1: merge after v9.0.0 is tagged. Closes #617.
Adds
arch.bootstrap.LocalBlockBootstrap(block_size, locality, *args, seed=None, **kwargs), the local block bootstrap of Paparoditis and Politis (2002), C. R. Acad. Sci.Paris, Ser. I 335(11), 959-962, for locally stationary series.
Design:
the
localityin observations (the paper's nB). The blocks are concatenated andtruncated to n.
update_indicesis vectorised NumPy (independent draws per block), with no compiledsampler.
CircularBlockBootstrap.localityis a read-only property likeblock_size, andclonekeeps both._check_samplingrequiresblock_size <= n.K >= n, every start is allowed, which is the moving block bootstrap.apply,cov,var, everyconf_intmethod, and seed and state handling workunchanged.
checks that "local" is rejected there.
1-based). The caveats are:
std_err_funcis the alternative;Validation:
is an independent base-R implementation of the paper: the indices are identical on 8
cases, which are stored in the tests.
0.0424 against the true 0.0408. The circular block bootstrap gives 0.11-0.12.
Tests:
test_local_block_bootstrap.py(186): exact support on edge cases; chi-squareuniformity of the starts; the trend check;
clone, seed, state and the read-onlyproperties; every
conf_intmethod, including the nested studentized interval; pandasand keyword inputs.
test_validation_local_block_bootstrap.py(232 rows).literal 1-based window, no truncation, and
clonedropping the locality.numpydoc lint 0, and the docs build has no new warnings.
Thanks to @yngvem for the proposal and the prototype.
🤖 Generated with Claude Code