HighDimensionalEconLab / DifferentiableStateSpaceModels.jl

MIT License
46 stars 1 forks source link

Add utility to check analytic steady states #157

Closed jlperla closed 2 years ago

jlperla commented 2 years ago

Code something like

function check_steady_state(m, p_d, p_f)
    sol = generate_perturbation(m, p_d, p_f)
    p_d_symbols = collect(Symbol.(keys(p_d)))
    p = order_vector_by_symbols(merge(p_d, p_f), m.mod.m.p_symbols)

    w = hcat(sol.y, sol.x) # get a vector for the proposed steadystate
    H = Vector{Floa64}(undef, length(w)) # allocate it, but leave undef to make sure we can see if it goes to 0 or not
    m.mod.m.H̄!(H, w, p)  # evaluate in place
    return norm(H) .≈ 0,
end 
  m = @include_example_module(Examples.rbc_observables)
    p_f = (ρ = 0.2, δ = 0.02, σ = 0.01, Ω_1 = 0.01)
    p_d = (α = 0.5, β = 0.95)
    @test  check_steady_state(m, p_d, p_f) == true