Re: [R] Time series example in Koop

From: Mike Marchywka <>
Date: Tue, 05 Apr 2011 10:01:56 -0400

> Date: Tue, 5 Apr 2011 07:35:04 -0500
> From:
> To:
> Subject: [R] Time series example in Koop
> I am trying to reproduce the output of a time series example in Koop's book
> "Analysis of Financial Data". Koop does the example in Excel and I used the
> ts function followed by the lm function.
> I am unable to get the exact coefficients that Koop gives - my coefficients
> are slightly different.

> After loading the data file and attaching the frame, my code reads:
> > y = ts(m.cap)
> > x = ts(oil.price)
> > d = ts.union(y,x,x1=lag(x,-1),x2=lag(x,-2),x3=lag(x,-3),x4=lag(x,-4))
> > mod1 = lm(y~x+x1+x2+x3+x4, data=d)
> > summary(mod1)
> Koop gives an intercept of 92001.51, while the code above gives 91173.32.
> The other coefficients are also slightly off.

The differences here seem to be of order 1 percent. You could suspect a number of things, including the published data file being published to less precision than that used in the book numbers(also look at number of points and see if any were added or dropped etc ). However, you may want to judge these based on what they do to your error which they presumably are both supposed to minimize but the calculation of which could be subject to various roundoff errors etc. Unless minimization is done analytically, it is of course subject to limitations of convergence or iteration count. Plotting both fits over the data and looking at residuals may help too. Depending on what you are really trying to do, you may want to change your error calculation etc.

Details of numerical results often depend on details of implementation. This is why stats packages that are not open source have limitations in applicability. With "real models" of course things get even more confusing.
( take a look at credit rating agencies results for example LOL).

> This is the example in Table 8.3 of Koop. I also attach a plain text version
> of the tab separated file "badnews.txt".
> badnews.txt
> Any light on why I do not get Koop's coefficients is most welcome...
> Ravi
                                          mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Apr 2011 - 15:17:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Apr 2011 - 15:40:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive