Skip to content

Commit

Permalink
Extend print statements of parameter moments for regime-switching
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwilliam77 committed Jan 4, 2021
1 parent 229c4a0 commit bf5ccf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/smc_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ function smc(loglikelihood::Function, parameters::ParameterVector{U}, data::Matr
fixed_para_inds = findall([ θ.fixed for θ in parameters])
free_para_inds = findall([!θ.fixed for θ in parameters])
para_symbols =.key for θ in parameters]
if regime_switching
# Concatenate regime symbols for each extra regimes
reg_switch_symbols = Vector{Symbol}(undef, n_para_rs)
ind = 0
for θ in parameters
if !isempty.regimes)
for i in 2:length.regimes[:value])
ind += 1
reg_switch_symbols[ind] = Symbol.key, "_reg$(i)")
end
end
end
push!(para_symbols, reg_switch_symbols...)
end

n_free_para = length(free_para_inds) + n_para_rs
free_para_inds = vcat(free_para_inds, collect(n_para+1:n_para+n_para_rs))
Expand Down
6 changes: 1 addition & 5 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ function init_stage_print(cloud::Cloud, para_symbols::Vector{Symbol};
if VERBOSITY[verbose] >= VERBOSITY[:high]
μ = weighted_mean(cloud)
σ = weighted_std(cloud)
# TODO: need to generalize this output for when parameters are regime-switching. Currently just prints the value
# store in p.value
println("Mean and standard deviation of parameter estimates")
for n=1:length(para_symbols)
for n = 1:length(para_symbols)
println("$(para_symbols[n]) = $(round(μ[n], digits = 5)), $(round(σ[n], digits = 5))")
end
end
Expand Down Expand Up @@ -174,8 +172,6 @@ function end_stage_print(cloud::Cloud, para_symbols::Vector{Symbol};
if VERBOSITY[verbose] >= VERBOSITY[:high]
μ = weighted_mean(cloud)
σ = weighted_std(cloud)
# TODO: need to generalize this output for when parameters are regime-switching. Currently just prints the value
# store in p.value
println("Mean and standard deviation of parameter estimates")
for n=1:length(para_symbols)
println("$(para_symbols[n]) = $(round(μ[n], digits = 5)), $(round(σ[n], digits = 5))")
Expand Down

0 comments on commit bf5ccf0

Please sign in to comment.