Skip to content

Commit d25519d

Browse files
Thore KockerolsThore Kockerols
authored andcommitted
fix plot cnd fcst!
1 parent 5b47ee1 commit d25519d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

ext/StatsPlotsExt.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,7 @@ function plot_conditional_forecast!(𝓂::ℳ,
31823182
cond_tmp[indexin(sort(axiskeys(conditions,1)),full_SS),axes(conditions,2)] .= conditions(sort(axiskeys(conditions,1)))
31833183
conditions = cond_tmp
31843184
end
3185-
3185+
31863186
if shocks isa SparseMatrixCSC{Float64}
31873187
@assert length(𝓂.exo) == size(shocks,1) "Number of rows of shocks argument and number of model variables must match. Input to shocks has " * repr(size(shocks,1)) * " rows but the model has " * repr(length(𝓂.exo)) * " shocks: " * repr(𝓂.exo)
31883188

@@ -3207,7 +3207,7 @@ function plot_conditional_forecast!(𝓂::ℳ,
32073207
elseif isnothing(shocks)
32083208
shocks = Matrix{Union{Nothing,Float64}}(undef,length(𝓂.exo),periods)
32093209
end
3210-
3210+
32113211
args_and_kwargs = Dict(:run_id => length(conditional_forecast_active_plot_container) + 1,
32123212
:model_name => 𝓂.model_name,
32133213
:conditions => conditions[:,1:periods_input],
@@ -3314,7 +3314,7 @@ function plot_conditional_forecast!(𝓂::ℳ,
33143314
shocks_idx = Union{Int,Nothing}[]
33153315

33163316
for init in diffdict[:shocks]
3317-
if all(isnothing, init)
3317+
if isnothing(init) || all(isnothing, init)
33183318
push!(shocks_idx, nothing)
33193319
else
33203320
for (i,u) in enumerate(unique_shocks)
@@ -3336,7 +3336,7 @@ function plot_conditional_forecast!(𝓂::ℳ,
33363336
conditions_idx = Union{Int,Nothing}[]
33373337

33383338
for init in diffdict[:conditions]
3339-
if all(isnothing, init)
3339+
if isnothing(init) || all(isnothing, init)
33403340
push!(conditions_idx, nothing)
33413341
else
33423342
for (i,u) in enumerate(unique_conditions)
@@ -3521,9 +3521,19 @@ function plot_conditional_forecast!(𝓂::ℳ,
35213521
if length(cond_idx) > 0
35223522
SS = k[:reference_steady_state][var_idx]
35233523

3524+
vals = vcat(k[:conditions], k[:shocks])[var_idx, cond_idx]
3525+
3526+
if k[:conditions_in_levels]
3527+
vals .-= SS
3528+
end
3529+
3530+
if same_ss
3531+
vals .+= SS
3532+
end
3533+
35243534
StatsPlots.scatter!(p,
3525-
cond_idx,
3526-
k[:conditions_in_levels] ? vcat(k[:conditions], k[:shocks])[var_idx,cond_idx] : vcat(k[:conditions], k[:shocks])[var_idx,cond_idx] .+ SS,
3535+
cond_idx,
3536+
vals,
35273537
label = "",
35283538
marker = gr_back ? :star8 : :pentagon,
35293539
markerstrokewidth = 0,

0 commit comments

Comments
 (0)