Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DynareJulia
KalmanFilterTools.jl
Commits
b117d301
Commit
b117d301
authored
Dec 17, 2019
by
MichelJuillard
Browse files
removing obsolete code
Modified-by:
Michel Juillard
<
michel.juillard@mjui.fr
>
parent
8cbc3a97
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/KalmanFilterTools.jl
View file @
b117d301
...
...
@@ -822,78 +822,6 @@ function diffuse_kalman_likelihood(Y::Matrix{U},
LIK
end
#=
function univariate_step(t, Y, Z, H, T, QQ, a, Pinf, Pstar, diffuse_kalman_tol, kalman_tol, ws)
llik = 0
for i=1:size(Y, 1)
Zi = view(Z, i, :)
prediction_error = get_prediction_error(Y, Z, a, i, t)
Fstar = get_Fstar!(Zi, Pstar, H[i], ws.uKstar)
Finf = get_Finf!(Zi, Pstar, ws.uKstar)
# Conduct check of rank
# Pinf and Finf are always scaled such that their norm=1: Fstar/Pstar, instead,
# depends on the actual values of std errors in the model and can be badly scaled.
# experience is that diffuse_kalman_tol has to be bigger than kalman_tol, to ensure
# exiting the diffuse filter properly, avoiding tests that provide false non-zero rank for Pinf.
# Also the test for singularity is better set coarser for Finf than for Fstar for the same reason
if Finf > diffuse_kalman_tol # F_{\infty,t,i} = 0, use upper part of bracket on p. 175 DK (2012) for w_{t,i}
ws.Kinf_Finf .= ws.uKinf./Finf
a .+= prediction_error.*ws.Kinf_Finf
# Pstar = Pstar + Kinf*(Kinf_Finf'*(Fstar/Finf)) - Kstar*Kinf_Finf' - Kinf_Finf*Kstar'
ger!( Fstar/Finf, ws.uKinf, ws.Kinf_Finf, Pstar)
ger!( -1.0, ws.uKstar, ws.Kinf_Finf, Pstar)
ger!( -1.0, ws.Kinf_Finf, ws.uKstar, Pstar)
# Pinf = Pinf - Kinf*Kinf_Finf'
ger!(-1.0, ws.uKinf, ws.Kinf_Finf, Pinf)
llik += log(Finf)
elseif Fstar > kalman_tol
llik += log(Fstar) + prediction_error*prediction_error/Fstar
a .+= ws.uKstar.*(prediction_error/Fstar)
ger!(-1/Fstar, ws.uKstar, ws.uKstar, Pstar)
else
# do nothing as a_{t,i+1}=a_{t,i} and P_{t,i+1}=P_{t,i}, see
# p. 157, DK (2012)
end
end
return llik
end
function univariate_step(t, Y, Z, H, T, QQ, a, Pinf, Pstar, diffuse_kalman_tol, kalman_tol, pattern, ws)
llik = 0
for i=1:size(pattern, 1)
Zi = view(Z, pattern[i], :)
prediction_error = get_prediction_error(Y, Z, a, pattern[i], t)
Fstar = get_Fstar!(Zi, Pstar, H[i], ws.uKstar)
Finf = get_Finf!(Zi, Pstar, ws.uKstar)
# Conduct check of rank
# Pinf and Finf are always scaled such that their norm=1: Fstar/Pstar, instead,
# depends on the actual values of std errors in the model and can be badly scaled.
# experience is that diffuse_kalman_tol has to be bigger than kalman_tol, to ensure
# exiting the diffuse filter properly, avoiding tests that provide false non-zero rank for Pinf.
# Also the test for singularity is better set coarser for Finf than for Fstar for the same reason
if Finf > diffuse_kalman_tol # F_{\infty,t,i} = 0, use upper part of bracket on p. 175 DK (2012) for w_{t,i}
ws.Kinf_Finf .= ws.uKinf./Finf
a .+= prediction_error.*ws.Kinf_Finf
# Pstar = Pstar + Kinf*(Kinf_Finf'*(Fstar/Finf)) - Kstar*Kinf_Finf' - Kinf_Finf*Kstar'
ger!( Fstar/Finf, ws.uKinf, ws.Kinf_Finf, Pstar)
ger!( -1.0, ws.uKstar, ws.Kinf_Finf, Pstar)
ger!( -1.0, ws.Kinf_Finf, ws.uKstar, Pstar)
# Pinf = Pinf - Kinf*Kinf_Finf'
ger!(-1.0, ws.uKinf, ws.Kinf_Finf, Pinf)
llik += log(Finf)
elseif Fstar > kalman_tol
llik += log(Fstar) + prediction_error*prediction_error/Fstar
a .+= ws.uKstar.*(prediction_error/Fstar)
ger!(-1/Fstar, ws.uKstar, ws.uKstar, Pstar)
else
# do nothing as a_{t,i+1}=a_{t,i} and P_{t,i+1}=P_{t,i}, see
# p. 157, DK (2012)
end
end
return llik
end
=#
# Filters
function
kalman_filter!
(
Y
::
AbstractArray
{
U
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment