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
Dynare
particles
Commits
ddc5b5b6
Commit
ddc5b5b6
authored
Jan 23, 2017
by
Johannes Pfeifer
Committed by
GitHub
Jan 23, 2017
Browse files
Properly terminate nonlinear_kalman_filter if non-positive definite matrices are encountered
Otherwise, crashes can happen during mode-finding
parent
285d5c17
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/nonlinear_kalman_filter.m
View file @
ddc5b5b6
...
...
@@ -152,8 +152,18 @@ for t=1:sample_size
KalmanFilterGain
=
PredictedStateAndObservedCovariance
/
PredictedObservedVariance
;
StateVectorMean
=
PredictedStateMean
+
KalmanFilterGain
*
PredictionError
;
StateVectorVariance
=
PredictedStateVariance
-
KalmanFilterGain
*
PredictedObservedVariance
*
KalmanFilterGain
'
;
StateVectorVarianceSquareRoot
=
chol
(
StateVectorVariance
)
'
;
PredictedObservedVarianceSquareRoot
=
chol
(
PredictedObservedVariance
)
'
;
[
StateVectorVarianceSquareRoot
,
p
]
=
chol
(
StateVectorVariance
,
'lower'
);
if
p
LIK
=-
Inf
;
lik
(
t
)
=-
Inf
;
return
end
[
PredictedObservedVarianceSquareRoot
,
p
]
=
chol
(
PredictedObservedVariance
,
'lower'
);
if
p
LIK
=-
Inf
;
lik
(
t
)
=-
Inf
;
return
end
end
lik
(
t
)
=
log
(
probability2
(
0
,
PredictedObservedVarianceSquareRoot
,
PredictionError
)
)
;
end
...
...
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