[R-sig-finance] More info: zoo 0.9-1

Gabor Grothendieck ggrothendieck at myway.com
Thu Dec 23 20:31:02 CET 2004



> Another new feature of zoo which fills a gap in R is that it allows for
> regression based on zoo series. In particular, it is also possible to fit
> dynamic linear regression models (where functions like diff() or lag() are
> used in the formula specification). Gabor and I have been struggling a bit
> with the design of this feature and the current solution is probably not
> the best one possible. Therefore, we would be happy about feedback and
> suggestions about this feature in particular but also the package in
> general.

I just wanted to add some color to this.  Three versions of
the dynamic regression code were developed.  

1. The first involved modifying the R lm function to accept zoo
series based on some code of Whit Armstrong.  (Whit 
is the maintainer of the `its' package.)  This was never 
released. 

2. The second version (which is in the current zoo release) is
completely different and involves no modification to 
any standard R code.  Unlike the first version which was specific 
to lm, this second version is completely general and applies not
only to lm but any regression or other formula-based
function that is written in the same way as lm (e.g. glm,
xtabs, rq from quantreg, svm from e1071, etc.).  This second
version works not only with zoo but also with ts.  The
main disadvantage is that one must surround the
formula argument with an I to tell it to intercept the
formula, e.g.  lm( I( diff(y) ~ lag(x1)+x2 ) ).   

2a. A variant of this second version is to provide the second
version together with convenience wrappers so that
dynlm(...whatever...) might be used in place of
lm(I(...whatevfer...)).  This eliminates the I though it
introduces a plethora of new function names while the rest
of zoo introduces very few new function names since zoo
mostly extends base generics and therefore just extends the
use of existing names to the zoo context.

3. The third version (which we have running but at this time
has not been released) is equally general to the second version 
and has the added advantage that the I() is not required.
The disadvantage of version three is that it requires 
replacing one of the standard R functions with an upwardly
compatible version that also handles this context.



More information about the R-sig-finance mailing list