Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kalman Filter: Make sure that VCOV matrices return true when using ishermite() #233

Open
IljaK91 opened this issue Jan 31, 2019 · 0 comments

Comments

@IljaK91
Copy link
Contributor

IljaK91 commented Jan 31, 2019

I have the following issue using the Kalman-Filter. Start with the following setup (the numbers don't really matter):

A = [0.4 0.; 0. 0.9]
G = [1. 0.6; 1. 0.]
R = [0. 0.; 0. 0.5]
Q = [1. 0.; 0. 1.5]

k = Kalman(A,G,Q,R)
Sigma_Inf, K_inf = stationary_values(k)
ishermitian(Sigma_Inf) -> false
Sigma_Inf ≈ conj(Sigma_Inf) -> true
set_state!(k,[0;0],Sigma_Inf)
update!(k,[1. ;1.])
update!(k,[1. ;1.])
ishermitian(k.cur_sigma) -> false
k.cur_sigma ≈ conj(k.cur_sigma) -> true

This is in both cases due to

k.cur_sigma[1,2] ≈ conj(k.cur_sigma[2,1]) -> true
k.cur_sigma[1,2] == conj(k.cur_sigma[2,1]) -> false

Now I am not sure if this warrants changes inside the ishermitian() function, i.e. changing == to , or if inside this package we should make sure that k.cur_sigma[1,2] == conj(k.cur_sigma[2,1]) holds exactly.

What do you guys think?

In case you wonder why this may be important: Some other functions that take a VCOV matrix (e.g. qnwnorm) control if the VCOV matrix is indeed Hermitian. A natural application would be

Kalman-Filtering -> obtaining estimates and vcov -> using these to form expectations over another function:

nodes, weights = qnwnorm(10,k.cur_x_hat,k.cur_sigma)

PosDefException: matrix is not Hermitian; Cholesky factorization failed.
in top-level scope at base\none
in qnwnorm at QuantEcon\7w41U\src\quad.jl:573
in qnwnorm at QuantEcon\7w41U\src\quad.jl:555 
in cholesky at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275 
in cholesky at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275 
in #cholesky#101 at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:275 
in #cholesky! at base\none 
in #cholesky! at base\none 
in #cholesky!#97 at stdlib\v1.1\LinearAlgebra\src\cholesky.jl:182
in checkpositivedefinite at stdlib\v1.1\LinearAlgebra\src\factorization.jl:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant