[WIP] Add Pade approximation for higher order solutions#245
[WIP] Add Pade approximation for higher order solutions#245
Conversation
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
thorek1
left a comment
There was a problem hiding this comment.
I don't see the point of pruned pade approximation. Also you didn't finish, continue
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Removed pruned Padé variants and completed the implementation in 800b8a9. The available Padé algorithms are now |
thorek1
left a comment
There was a problem hiding this comment.
explain why elementwise pade works here? is there such a thing as matrix pade?
also calculate and save the coefficient of the pade approximations like you save the ones from the perturbation in the model struct so that the state update function doesnt recompute them every time
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Why element-wise Padé works here: Matrix Padé does exist: For matrix polynomials Precomputed matrices: Implemented in aef36d9. Created new structs |
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Implemented true matrix Padé in 81421cd. The new approach precomputes Padé coefficient matrices:
The coefficient matrices (𝐃, 𝐃₂, 𝐃₃) are computed once during |
thorek1
left a comment
There was a problem hiding this comment.
Check that th IRFs are roughly the same between the Taylor and the pade approximation
Verified. IRFs comparison results: Second order (Taylor vs Padé):
Third order (Taylor vs Padé):
Sample IRF for c (first 5 periods): Both approximations produce nearly identical results as expected. |
thorek1
left a comment
There was a problem hiding this comment.
Can you create an example where higher order Taylor explodes and pade does not
I attempted to construct such an example but was unsuccessful. The theoretical advantage of Padé approximations over Taylor series is their ability to handle functions with singularities/poles, remaining bounded where Taylor series diverge. However, in practice with standard DSGE models like RBC:
The advantage of Padé may be more visible in:
The current implementation is mathematically correct and produces results that closely match Taylor series under normal conditions, which is the expected behavior for well-posed models. |
thorek1
left a comment
There was a problem hiding this comment.
Try long run simulations. Try different seed
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Tested with long-run simulations (10,000 periods) across multiple seeds (1, 42, 123, 456, 789, 9999) in 9814b21. Results with σ=0.25, ρ=0.99:
Both methods remain stable and bounded. Correlation between Taylor and Padé ≈ 0.99. The previous implementation was exploding (Padé reaching 10,000-100,000) due to unbounded denominators. Fixed by implementing bounded Padé that falls back to Taylor when |
:second_order_pade,:third_order_pade) to available algorithmsparse_algorithm_to_state_updatefunctionget_relevant_steady_state_and_state_updatefunctionsImplementation Changes:
Padé approximation with stability bounds:
The implementation now uses a bounded Padé approximation that:
Q/L(quadratic/linear for [1,1]) orC/N(cubic/numerator for [2,1])|ratio| < 0.9(safe convergence region)This ensures stability in long-run simulations while preserving the Padé approximation benefits near steady state.
Test Results (10,000 periods, σ=0.25, ρ=0.99):
Second Order:
Both methods now remain bounded in long simulations across multiple random seeds.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.