From 1fd8e4e279b082413ef88947026f7d3dcbbbe926 Mon Sep 17 00:00:00 2001 From: Pearl Li Date: Tue, 22 May 2018 14:36:51 -0400 Subject: [PATCH] Squash presample removal bugs --- src/filters/kalman_filter.jl | 13 +++++-------- src/smoothers/hamilton_smoother.jl | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/filters/kalman_filter.jl b/src/filters/kalman_filter.jl index 2ad7e54..e5c7687 100644 --- a/src/filters/kalman_filter.jl +++ b/src/filters/kalman_filter.jl @@ -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 diff --git a/src/smoothers/hamilton_smoother.jl b/src/smoothers/hamilton_smoother.jl index cd19954..39a581b 100644 --- a/src/smoothers/hamilton_smoother.jl +++ b/src/smoothers/hamilton_smoother.jl @@ -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