Skip to content

Commit

Permalink
Squash presample removal bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pearlzli committed May 22, 2018
1 parent 1dc32ed commit 1fd8e4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/filters/kalman_filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,16 @@ function remove_presample!(Nt0::Int, loglh::Vector{S},
s_filt::Matrix{S}, P_filt::Array{S, 3};
outputs::Vector{Symbol} = [:loglh, :pred, :filt]) where {S<:AbstractFloat}
if Nt0 > 0
Nt = length(loglh)
insample = (Nt0+1):Nt

if :loglh in outputs
loglh = loglh[insample]
loglh = loglh[(Nt0+1):end]
end
if :pred in outputs
s_pred = s_pred[:, insample]
P_pred = P_pred[:, :, insample]
s_pred = s_pred[:, (Nt0+1):end]
P_pred = P_pred[:, :, (Nt0+1):end]
end
if :filt in outputs
s_filt = s_filt[:, insample]
P_filt = P_filt[:, :, insample]
s_filt = s_filt[:, (Nt0+1):end]
P_filt = P_filt[:, :, (Nt0+1):end]
end
end
return loglh, s_pred, P_pred, s_filt, P_filt
Expand Down
2 changes: 1 addition & 1 deletion src/smoothers/hamilton_smoother.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function hamilton_smoother(regime_indices::Vector{Range{Int}}, y::Matrix{S},

# Trim the presample if needed
if Nt0 > 0
insample = Nt0+1:T
insample = Nt0+1:Nt
s_smth = s_smth[:, insample]
ϵ_smth = ϵ_smth[:, insample]
end
Expand Down

0 comments on commit 1fd8e4e

Please sign in to comment.