Skip to content

Implement parameter breakpoints for get_irf to support time-varying parameters#243

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-breakpoints-to-function-calls
Draft

Implement parameter breakpoints for get_irf to support time-varying parameters#243
Copilot wants to merge 4 commits intomainfrom
copilot/add-breakpoints-to-function-calls

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Enables parameter values to change at specific periods during IRF computation by passing a KeyedArray with parameter values indexed by period.

Changes

Type system

  • Extended ParameterType to accept KeyedArray{Float64} for breakpoint specifications

Parsing logic

  • Added parse_parameter_breakpoints() to extract parameter-period mappings from KeyedArray
  • Dynamically determines dimension ordering using type introspection of NamedDimsArray
  • Supports both Time and Periods dimension names

Model resolution

  • Added apply_parameter_breakpoint!() helper that updates parameters, re-solves model, and returns new state update function
  • Modified get_irf() to detect and parse breakpoint specifications
  • Updated compute_irf_responses() and irf() signatures to propagate breakpoint context
  • Modified IRF loops to check for and apply breakpoints at each period

Usage

using MacroModelling, AxisKeys

# Parameter changes at periods 1, 5, and 30
break_points = KeyedArray([0.4 0.3 0.25]; Variable = [:ctrend], Time = [1, 5, 30])

irfs = get_irf(Smets_Wouters_2007, 
               parameters = break_points,
               shocks = :none,
               levels = true,
               algorithm = :pruned_second_order)

Limitations

  • Model is re-solved at each breakpoint period (performance cost scales with number of breakpoints)
  • Output uses final steady state for level calculations across all periods
Original prompt

Implement the possibility to pass on breakpoints to function calls. For example you provide input to the parameters argument that details parameter values for specific periods. Internally the model would start with the current set of parameters and once the first period is reached where a value is defined in the input the model would take it into account from there onwards.

For get_irf this could look something like this:

using MacroModelling

include("../models/Smets_Wouters_2007.jl")

break_points = KeyedArray([.4,.3,.25]', Variable =[:ctrend], Time = [1,5,30])

irfs = get_irf(Smets_Wouters_2007, parameters = break_points, shocks = :none, levels = true, algorithm = :pruned_second_order)

So in the first period c trend is 0.4 in the fifth it goes to 0.3 and in 30th to 0.25


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 15, 2026 06:21
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
…dimension detection

Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Copilot AI changed the title [WIP] Add possibility to pass breakpoints to function calls Implement parameter breakpoints for get_irf to support time-varying parameters Jan 15, 2026
Copilot AI requested a review from thorek1 January 15, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants