Repository navigation
FIX: step LQMarkov.compute_sequence with the current regime - #992
Open
cristianchiriac wants to merge 1 commit into
Open
cristianchiriac wants to merge 1 commit into
cristianchiriac wants to merge 1 commit into
Conversation
The simulation moved x_t to x_{t+1} with A(s_{t+1}), B(s_{t+1}) and
C(s_{t+1}) while u_t = -F(s_t) x_t was chosen for regime s_t, so paths
that switch between regimes with different A, B or C did not follow the
documented law of motion x_{t+1} = A(s_t) x_t + B(s_t) u_t + C(s_t) w_{t+1}.
Step each period with the regime that is current at its start.
Fixes QuantEcon#985
|
Thanks for the pull request, @cristianchiriac! QuantEcon welcomes AI-assisted contributions under its Code of AI Use. Every pull request carries one
This comment is posted on every external pull request that arrives without the line, so it is not a flag on yours. Nothing is blocked; a maintainer reads the reply. |
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.
Fixes #985.
LQMarkov.compute_sequencemovedx_ttox_{t+1}withA(s_{t+1}),B(s_{t+1})andC(s_{t+1}), whileu_t = -F(s_t) x_twas chosen fors_t. On paths that switch between regimes with differentA,BorC, the simulated path did not follow the documented law of motion and its realised cost did not matchx0' P(s_0) x0.This uses the single forward loop suggested in the issue: each step uses the regime that is current at its start, and
Cw_pathgoes away. The random draws are unchanged (states first, thenw), sostateandw_pathare the same for a given seed, and paths whose regimes shareA,BandCare unchanged. The existing seeded tests (test_scalar_sequences_with_seed,test_mat_sequences) pass as before.Test:
test_compute_sequence_switching_regimes, the regression test from the issue (alternating regimes with differentAandB). It checksx_{t+1} = A(s_t) x_t + B(s_t) u_tand that the realised discounted cost equalsP(s_0). It fails onmainand passes with this change. With the issue's reproducer, the realised cost is now1.7903655699vsP(s_0) = 1.7903655698for seed 0 and1.351812536for both with seed 1.pytest quantecon/tests/test_lqcontrol.py: 19 passedpytest quantecon -m "not slow": 697 passed (test_filter.pyandtest_quad.pywere not collected because pandas isn't installed in my environment)flake8 --select=F401,F405,E231is clean on both filesI left the
u_0, ..., u_Twording in theLQandLQMarkovdocstrings, which the issue also mentions, for a separate change.