-
Notifications
You must be signed in to change notification settings - Fork 17
Add comprehensive solution algorithms documentation page #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot the higher order algorithm works in the flattened 2d space. can you lay out how the original problem formulation in terms of tensors looks like and how that is translated to the flattened space (incl what the permutation matrices do)
… matrices Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Added a comprehensive section "Tensor Representation and Flattening" that explains:
The section includes a worked example showing the explicit 9×6 compression matrix C₂ for a 3-variable case. Commit: 5f39819 |
thorek1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot for the first order solution there is an equation the first order solution must fulfil and then there is the algorithm to get to the matrix that fulfils that equation. write that equation down at the beginning of the section explaining the first order algorithm and then do the same for the higher order algorithms
…m sections Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Added "The Equation to Solve" subsections at the beginning of each perturbation order section: First-order: Shows the fundamental condition that S₁ must satisfy when substituted into the linearized model equations Second-order: Presents both the direct form involving ∇₂ (Hessian) and the equivalent generalized Sylvester equation A S₂ B + C = S₂ Third-order: Shows the equation involving ∇₃ (third-order derivatives), permutations, and coupling with S₂, plus the equivalent Sylvester form Each section now clearly separates:
This makes it clear that the algorithm sections describe methods to find matrices satisfying these specific equations. Commit: 3472495 |
thorek1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot shouldn't there be more elements from the second order solution in "The third-order solution matrix S_3 must satisfy"
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Expanded the third-order equation to include additional S₂ interaction terms:
The equation now reflects that S₂ appears in several forms: coupled with S₁ through Kronecker products (with various permutations), multiplied by the Jacobian ∇₊ to capture expectation effects, and in Hessian terms through ∇₂. Commit: a57a5fe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot since this is a Taylor expansion shouldn't all of this be nested, as in I should find the first order condition (equation the solution must satisfy) in the higher order ones...?
thorek1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot since this is a Taylor expansion shouldn't all of this be nested, as in I should find the first order condition (equation the solution must satisfy) in the higher order ones...?
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Restructured the equations to show the nested Taylor expansion structure: Second-order: Now explicitly shows the first-order operator (∇₊ S₁ [S₁ʸ, 0]ᵀ + ∇₀) acting on S₂, plus the new second-order terms from ∇₂. Added a "Key insight" note explaining that the first-order condition for S₁ is already satisfied. Third-order: Shows the same first-order operator acting on S₃, plus third-order terms (∇₃ with S₁), plus second-order interaction terms (∇₂ with S₁ and S₂), plus expectation effects (∇₊ S₂). Added a "Key insight" emphasizing that both first and second-order conditions are already satisfied, so we only balance new third-order terms. The equations now clearly show:
This makes the mathematical structure much clearer - higher-order solutions don't re-solve the lower-order problems, they just add corrections. Commit: 110c3b1
Restructured the equations to show the nested Taylor expansion structure: Second-order: Now explicitly shows the first-order operator (∇₊ S₁ [S₁ʸ, 0]ᵀ + ∇₀) acting on S₂, plus the new second-order terms from ∇₂. Added a "Key insight" note explaining that the first-order condition for S₁ is already satisfied. Third-order: Shows the same first-order operator acting on S₃, plus third-order terms (∇₃ with S₁), plus second-order interaction terms (∇₂ with S₁ and S₂), plus expectation effects (∇₊ S₂). Added a "Key insight" emphasizing that both first and second-order conditions are already satisfied, so we only balance new third-order terms. The equations now clearly show:
This makes the mathematical structure much clearer - higher-order solutions don't re-solve the lower-order problems, they just add corrections. Commit: 110c3b1 |
This PR adds a new documentation page (
docs/src/tutorials/solution_algorithms.md) that provides detailed explanations of the perturbation solution algorithms implemented in MacroModelling.jl for solving DSGE models at first, second, and third order.Overview
The documentation addresses the need for in-depth technical documentation of the solution methods, including exact mathematical formulations, step-by-step algorithms, and matrix construction details.
Content
Fundamental Equations with Nested Taylor Expansion Structure
Each perturbation order section begins with "The Equation to Solve" that clearly shows the nested structure of the Taylor expansion:
Each section includes "Key insights" explaining that lower-order conditions are already satisfied, so higher-order solutions only balance new residual terms. This clearly demonstrates that:
Tensor Representation and Flattening
Comprehensive explanation of how the algorithm works in flattened 2D space:
Detailed Algorithm Documentation
First-Order Perturbation Solution
Second-Order Perturbation Solution
Third-Order Perturbation Solution
Additional Topics
Integration
The page is integrated into
docs/make.jlas a tutorial, positioned after basic tutorials and before advanced calibration and estimation tutorials.Example Usage
This documentation provides users with complete understanding from theory to implementation: the fundamental equations with proper nested Taylor expansion structure, how tensor problems are translated to the flattened 2D space (including compression and permutation matrices), and the step-by-step algorithms to compute solutions efficiently.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.