Skip to content

Commit

Permalink
Revert "Free parameter indices called through function only"
Browse files Browse the repository at this point in the history
This reverts commit 200b218.
  • Loading branch information
chenwilliam77 committed Jan 5, 2021
1 parent 25e9530 commit b89156d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/smc_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,23 @@ function smc(loglikelihood::Function, parameters::ParameterVector{U}, data::Matr

n_para = length(parameters)
n_para_rs = 0 # number of regime switching parameter values (excluding regime 1 values), i.e. if one parameter has 3 regimes, then n_para_rs = 2
n_para_rs_free = []
for para in parameters
if !isempty(para.regimes)
for (ind, val) in para.regimes[:value]
if ind != 1
n_para_rs += 1
if (haskey(para.regimes, :fixed) && !para.regimes[:fixed][ind]) ||
(!haskey(para.regimes, :fixed) && !para.fixed)
append!(n_para_rs_free, n_para_rs)
end
end
end
end
end

fixed_para_inds = get_fixed_para_inds(parameters; regime_switching = regime_switching, toggle = toggle)
free_para_inds = get_free_para_inds( parameters; regime_switching = regime_switching, toggle = toggle)
# fixed_para_inds = get_fixed_para_inds(parameters; regime_switching = regime_switching, toggle = toggle)
# free_para_inds = get_free_para_inds( parameters; regime_switching = regime_switching, toggle = toggle)
fixed_para_inds = findall([(haskey.regimes, :fixed) && length.regimes) >= 1) ? θ.regimes[:fixed][1] : θ.fixed for θ in parameters])
free_para_inds = findall([(haskey.regimes, :fixed) && length.regimes) >= 1) ? !θ.regimes[:fixed][1] : !θ.fixed for θ in parameters])
para_symbols =.key for θ in parameters]
Expand All @@ -215,7 +229,7 @@ function smc(loglikelihood::Function, parameters::ParameterVector{U}, data::Matr
push!(para_symbols, reg_switch_symbols...)
end

n_free_para = length(free_para_inds)
# n_free_para = length(free_para_inds)

n_free_para = length(free_para_inds) + length(n_para_rs_free)
free_para_inds = vcat(free_para_inds, collect(n_para+1:n_para+n_para_rs)[n_para_rs_free])
Expand Down

0 comments on commit b89156d

Please sign in to comment.