(dead) Implementation of "Time-varying vector autoregressive models with stochastic volatility" by Kostas Triantafyllopoulos available at arxiv link below
C++ Python
Switch branches/tags
Nothing to show
Pull request Compare This branch is 2 commits ahead of maxfdama:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
PyKf.pyx
README
kf.cpp
kf.py
kf_speed.cpp
kf_test.cpp
setup.py

README

Implementation of "Time-varying vector autoregressive models with stochastic volatility" by Kostas Triantafyllopoulos available at http://arxiv.org/abs/0802.0220 and published in Journal of Applied Statistics Vol. 38, No. 2 Feb 2011.

kf stands for Kalman Filter. This package can be seen as an advanced Kalman Filter and the name is short. 

-------------

kf.cpp requires Boost uBLAS
kf_test.cpp and kf_speed.cpp require Boost Test and Boost Random 

Boost Installation on Ubuntu:
$ sudo apt-get install libboost-dev libboost-doc 

-------------

Test with 
g++ kf_test.cpp; ./a.out

The correct output is
Running N test cases...

*** No errors detected


Test runtime with
g++ kf_speed.cpp; ./a.out

Running 1 test case...
gUnivariate runtime = 1
Bivariate runtime = 3
10-variate runtime = 47

*** No errors detected


Should compile with no warnings under -Wall.
Also runnable with g++ -O3 compiler optimization flag set.

-------------

Please see test cases and code for usage.

-------------

Note that there is one errata in the paper to mention:
In section 3.1, 
Pt = Rt − Kt K't / Qt
should be 
Pt = Rt − Kt K't * Qt

-------------

Advanced C++ features: templates, default template arguments, operator overloading, overloaded operator overloading, default arguments, inline functions, multiple returns with reference parameters, macros

------------- 

Thanks to:
rgarcia



-------------
Python wrapper:

bshanks is trying to make a Python wrapper. Currently it doesn't compile:

$ python setup.py build_ext --inplace
running build_ext
cythoning PyKf.pyx to PyKf.cpp
building 'PyKf' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c PyKf.cpp -o build/temp.linux-x86_64-2.7/PyKf.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
PyKf.cpp:318:12: error: type/value mismatch at argument 1 in template parameter list for ‘template<long unsigned int p> class KF’
PyKf.cpp:318:12: error:   expected a constant of type ‘long unsigned int’, got ‘size_t {aka long unsigned int}’
PyKf.cpp: In function ‘int __pyx_pf_4PyKf_4PyKf___cinit__(PyObject*, PyObject*, PyObject*)’:
PyKf.cpp:621:66: error: type/value mismatch at argument 1 in template parameter list for ‘template<long unsigned int p> class KF’
PyKf.cpp:621:66: error:   expected a constant of type ‘long unsigned int’, got ‘size_t {aka long unsigned int}’
PyKf.cpp:621:69: error: expected primary-expression before ‘)’ token
PyKf.cpp:621:70: error: expected ‘)’ before ‘new’
PyKf.cpp: In function ‘PyObject* __pyx_pf_4PyKf_4PyKf_2__call__(PyObject*, PyObject*, PyObject*)’:
PyKf.cpp:670:11: error: ‘__pyx_v_yVar’ declared as reference but not initialized
PyKf.cpp:752:85: error: request for member ‘call’ in ‘*((__pyx_obj_4PyKf_PyKf*)__pyx_v_self)->__pyx_obj_4PyKf_PyKf::kf’, which is of non-class type ‘int’
error: command 'gcc' failed with exit status 1