First, this blog is coming a bit late than usual; sorry for that. I was traveling to my hometown(Delhi) for some occassion and couldn’t do much in last 3 days. I am thankful to Claudio for his support.
So, in this phase, as discussed, we continue to compose estimation methods for
ARMA/ARIMA. Good news - Most of method seem to be in place. Even if we manage to make atleast one or two; we seem to be in good position. Bad news - the estimation methods, I am hanging out with has lot of pre-requisitie. These requisites are both theoretical and technical. So, I’m currently initially coding them as I go. This comes with a plus. These methods will be extremely valuable in many other analysis. ;)
So, we started up with developing Kalman filter. Kalman filter is one of the crucial method for ARIMA model fit. It is primarily identified with constitution of 3 matrices -
- T Matrix : It is the coefficient matrix for the state vector in the state equation.
- R Matrix : It is the coefficient matrix for the state vector in the observation equation.
- Z Matrix: It is the selctor matrix.
Currently, these methods are available as
class methods of the new class -
ARIMA. It can be found here
The example snippet of T matrix code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
The complete coding of
R matrix is still pending.
While venturing into another estimation method; I encoutered Cholesky decomposition of matrix; and it took me by surprise. Cholesky decomposition is the decomposition of a symmetric matrix in the product of lower half of Hermitian matrix and it’s conjugate.
I implemented the following as extension of
Matrix here. Since the matrix has to be symmetric before it can be decomposed to Hermitian matrix, I also wrote down
is_symmetric? method to check if the matrix is symmetric or not. Though
symmetric? is present in Ruby Matrix 1.9+, to satisfy back compatibility with Ruby 1.8, it was necessary.
That’s pretty much for now.
Continuing the work.
- Ankur Goel