Skip to content

VAR, VECM, Kalman, ... non-R software recommendations?

4 messages · Jeffrey Todd Lins, Krishna Kumar, Achim Zeileis +1 more

#
Hi Dirk,

Yes, in stats there is a set of Kalman filter routines and you can use optim for likelihood estimation. 
I have used it for some state space modeling. There is a chapter in Zivot and Wang's book on the topic as well.

In addition initializing in the KF may be an important consideration - see Harvey and/or Durbin and Koopman.

I have never really used DSE for VAR, ended up writing the code elsewhere, outside of R, but you could look at gretl,
which is available under GNU GPL and written in C, it contains quite a few bits and pieces, I am assuming you can get the source.

Jeff





-----Original Message-----
From: r-sig-finance-bounces@stat.math.ethz.ch
[mailto:r-sig-finance-bounces@stat.math.ethz.ch]On Behalf Of Pijus
Virketis
Sent: Friday, August 20, 2004 7:37 PM
To: Dirk Eddelbuettel
Cc: R-sig-finance@stat.math.ethz.ch
Subject: RE: [R-sig-finance] VAR, VECM, Kalman,... non-R software
recommendations?


Dear Dirk,

As far as my personal experience goes, I needed to estimate such models
some time ago, when the R toolkit for this sort of thing was still
almost empty, so I chose to invest in STATA: it provides a fairly
complete set of functions to estimate VAR, SVAR and (as of two months
ago) VECM models, validate their results and stability, and calculate
all the frequently-needed derivatives, such as the MA forms (i.e. IRFs,
SIRFs, ...), etc. For what it's worth, I chose STATA over many other
contenders in the field because it seemed to have some of those R-like
pro-active qualities, like frequent updates, knowledgeable and involved
users, and accessible developers (to which I can personally attest after
running into a couple of bugs in the early SVAR code). The R-STATA
intercommunication is made possible by the foreign package, batch modes,
and good old ASCII. ;) STATA programming is a bit laborious, so I always
only farm out the absolute minimum to it, and do the remainder in R. As
you said, STATA let me "hit the ground running", and is really not a bad
compromise.

Of course, today R's own arsenal for time-series econometrics is shaping
up fast as well. Most significantly, there is now the CRAN urca package
by Bernhard Pfaff: it provides the means to estimate VECM models (both
the transitory and long-term flavours) and Johansen's co-integration
tests built on top them. Sadly, VAR/SVAR and associated battery of
helper functions are still not available, as far as I am aware.

As for the Kalman filter, there is the Kalman... family of functions in
stats: perhaps that's a good place to start? Sadly, I have not yet had a
chance to use space-state models in a proper project, so my knowledge of
the available tools and their relative capabilities is modest. Also, if
you can get to it, R. Carmona's neat book "Statistical Analysis of
Financial Series in S-Plus" (Springer, 2004) has a few sections
(6.2-6.7) on state-space models and Kalman filtering thereof (S code
included), with applications to finance.

Cheers,

Pijus
_______________________________________________
R-sig-finance@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance


This email may contain confidential and/or privileged inform...{{dropped}}
#
I have mucked around with the kalman for estimating time-varying betas.  
there was another interest
in cointegration stuff a few weeks back.

I will clean up my code, and put it up someplace.

One suggestion i have for R-SIGGERS is to have a place to post code like 
a repository.
Someplace like the elseiver computer physics code repository

 http://www.cpc.cs.qub.ac.uk/
for which you have to cough up $$$.  The R-SIG repository should be free.

The idea is already in place for some econometric journals where you 
have people uploading their data-sets and routines.
It would be nice to have a facility where one can upload the code with a 
little blurb of what the routines are doing.

any ideas.??.  I am sure there is a opensource thingie that accepts code 
and a little document and that allows users to rate/leave comments?

If anyone knows one let me know. We are going to see more and more of   
"How do I do foo goo in R ?"    or 
"I  know we can do boomoo in math$  but can you do it in R ?"

Just my 2 cents.
Jeffrey Todd Lins wrote:

            
#
On Fri, 20 Aug 2004 17:36:03 -0700 krishna kumar wrote:

            
There are several ways of doing that more generally with R (or other
statistics software). The most obvious idea is, of course, to write a
simple R package and post it on CRAN: this can contain the R functions,
data sets, help pages, further documentation in vignettes etc.
To document what your software is doing and how it can be used, there's
the possibility to submit the package plus documentation to the Journal
of Statistical Software
  http://www.jstatsoft.org/
either for the articles section or the code snippets.

Of course, a full package might seem overkill for some simpler things.
Maybe, it would be a good idea to start a snippet package for
computational finance and econometrics with R. Maybe, we can find a
volunteer who could put something together like Greg Warnes does with
the gregmisc package which hosts nifty code snippets by various authors.

Finally, really simple things could also be posted to the list(s) and
will then be archived anyway. But this would have to be really small
pieces of code, probably.

The advantage of a full CRAN package (possibly one containing snippets
by various authors) is that this is regularly checked and hence needs to
be actively maintained...and it comes in a standard format and can be
trivially accessed via install.packages() and update.packages().
In the repositories of the journals you often find old and out-dated
code which wasn't bug-fixed although mistakes might have been
discovered, with documentation that is insufficient or not easy to
access, data sets in different formats etc. 

Best,
Z
#
On Sat, Aug 21, 2004 at 01:34:14AM +0200, Achim Zeileis wrote:
[...]
A third option would be a wiki. Detlef Steuer once set one up and announced
it on r-help, but somehow it didn't get adopted. Wikis may have lower
barriers to entry, which can be an advantage. In an ideal world, the
community would edit the wiki to purge truly useless code.
Yes, that may be a very good compromise.
Yes, also possible, and probably the easiest method. We could start with
that, and even vet / extend code that way. 

So many ways to contribute code ;-)

Regards, Dirk