-
Notifications
You must be signed in to change notification settings - Fork 17
Add quadrature algorithm for stochastic steady state calculation #158
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: combine_plots
Are you sure you want to change the base?
Add quadrature algorithm for stochastic steady state calculation #158
Conversation
Co-authored-by: thorek1 <[email protected]>
Co-authored-by: thorek1 <[email protected]>
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.
- use QuasiMonteCarlo.jl for the sobol samples
- write a function similar to write_ss_check_function! that generates a function using the dynamic equations and has as input the parameters, the variables in non stochastic steady state (if so defined in the model), the state (all variables which are then mapped to the the respective timings), and the exogenous shocks.
- the optimisation routine that takes the parameters, steady state values and shock samples as given and finds the state that minimizes the residuals across shock draws
Co-authored-by: thorek1 <[email protected]>
I've refactored the quadrature implementation per your feedback:
f(residual, parameters, NSSS_vars, state_past, state_present, state_future, shocks)The function is stored in
Changes in commit cfca4f4 (to be pushed). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR implements a new
:quadraturealgorithm option forget_steady_statethat calculates the stochastic steady state by integrating out shocks using the dynamic equations of the model.Overview
The quadrature method provides an alternative approach to finding the stochastic steady state that uses quasi-random sampling and numerical integration with the model's dynamic equations rather than relying solely on perturbation solution terms.
Implementation Details
Algorithm
New Features
write_quadrature_dynamic_function!()similar towrite_ss_check_function!()that generates a compiled function from model's dynamic equationsoptimize_quadrature_sss()that takes parameters, steady state values, and shock samples as inputsArchitecture
The implementation follows established patterns in the codebase:
write_quadrature_dynamic_function!()generates a function with signature:f(residual, parameters, NSSS_vars, state_past, state_present, state_future, shocks)𝓂.quadrature_dynamic_funcfield (similar toSS_check_func)Usage Example
Testing
Tested successfully with the FS2000 model:
Additional Changes
src/MacroModelling.jlto define constants before use (fixes compilation error whereDEFAULT_VARIABLES_EXCLUDING_OBCwas undefined)erfinvimport from SpecialFunctions for inverse error function needed in normal distribution transformationFiles Changed
src/quadrature_sss.jl(new): Core implementation of the quadrature algorithm with modular functionssrc/get_functions.jl: Integration withget_steady_statefunctionsrc/MacroModelling.jl: Include order fix, QuasiMonteCarlo import, and dynamic function field initializationsrc/structures.jl: Addedquadrature_dynamic_funcfield to model structsrc/macros.jl: Initializequadrature_dynamic_funcin model macroProject.toml: Added QuasiMonteCarlo.jl dependencyOriginal 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.