A blog by Rob J Hyndman 

Twitter Gplus RSS

Posts Tagged ‘R’:


Forecasting annual totals from monthly data

Published on 15 May 2013

This ques­tion was posed on cross​val​i​dated​.com: I have a monthly time series (for 2009–2012 non-​​​​stationary, with sea­son­al­ity). I can use ARIMA (or ETS) to obtain point and inter­val fore­casts for each month of 2013, but I am inter­ested in fore­cast­ing the total for the whole year, includ­ing pre­dic­tion inter­vals. Is there an easy way in R to obtain inter­val fore­casts for the total for 2013? I’ve come across this prob­lem before in my con­sult­ing work, although I don’t think I’ve ever pub­lished my solu­tion. So here it is.

 
2 Comments  comments 

My new forecasting book is finally finished

Published on 21 April 2013

My new online fore­cast­ing book (writ­ten with George Athana­sopou­los) is now com­pleted. I pre­vi­ously described it on this blog nearly a year ago. In real­ity, an online book is never com­plete, and we plan to con­tin­u­ally update it. But it is now at the point where it is suit­able for course work, and con­tains exer­cises and ref­er­ences. We hope that users (espe­cially other lec­tur­ers) will sub­mit mate­ri­als such as slides and exer­cises, that can be shared on the web­site. For those want­ing a print ver­sion, we will be sell­ing it via Ama­zon in the next few months. The online ver­sion will remain freely avail­able. If other authors are inter­ested in this pub­lish­ing model, please see this page. The book is being pub­lished by OTexts, a new inno­v­a­tive pub­lish­ing com­pany I am estab­lish­ing. The fore­cast­ing book is our first pub­li­ca­tion, but we have three oth­ers that should be online within the next month or two. 

 
No Comments  comments 

ETS models now in EViews 8

Published on 1 March 2013

The ETS mod­el­ling frame­work devel­oped in my 2002 IJF paper (with Koehler, Sny­der and Grose), and in my 2008 Springer book (with Koehler, Ord and Sny­der), is now avail­able in EViews 8. I had no idea they were even work­ing on it, so it was quite a sur­prise to be told that EViews now includes ETS models.

 
No Comments  comments 

Removing white space around R figures

Published on 22 February 2013

When I want to insert fig­ures gen­er­ated in R into a LaTeX doc­u­ment, it looks bet­ter if I first remove the white space around the fig­ure. Unfor­tu­nately, R does not make this easy as the graphs are gen­er­ated to look good on a screen, not in a doc­u­ment. There are two things that can be done to fix this problem.

 
7 Comments  comments 

Out-​​of-​​sample one-​​step forecasts

Published on 14 February 2013

It is com­mon to fit a model using train­ing data, and then to eval­u­ate its per­for­mance on a test data set. When the data are time series, it is use­ful to com­pute one-​​​​step fore­casts on the test data. For some rea­son, this is much more com­monly done by peo­ple trained in machine learn­ing rather than sta­tis­tics. If you are using the fore­cast pack­age in R, it is eas­ily done with ETS and ARIMA mod­els. For exam­ple: library(forecast) fit <- ets(trainingdata) fit2 <- ets(testdata, model=fit) onestep <- fitted(fit2) Note that the sec­ond call to ets does not involve the model being re-​​​​estimated. Instead, the model obtained in the first call is applied to the test data in the sec­ond call. This works because fit­ted val­ues are one-​​​​step fore­casts in a time series model. The same process works for ARIMA mod­els when ets is replaced by Arima or auto.arima. Note that it does not work with the arima func­tion from the stats pack­age. One of the rea­sons I wrote Arima (in the fore­cast pack­age) is to allow this sort of thing to be done.

 
11 Comments  comments 

Batch forecasting in R

Published on 7 January 2013

I some­times get asked about fore­cast­ing many time series auto­mat­i­cally. Here is a recent email, for exam­ple: I have looked but can­not find any info on gen­er­at­ing fore­casts on mul­ti­ple data sets in sequence. I have been using analy­sis ser­vices for sql server to gen­er­ate fit­ted time series but it is too much of a black box (or I don’t know enough to tweak/​​manage the inputs). In short, what pack­age should I research that will allow me to load data, gen­er­ate a fore­cast (pre­sum­ably best fit), export the fore­cast then repeat for a few thou­sand items. I have read that R does not like ‘loops’ but not sure if the cur­rent cpu power off­sets that or not. Any guid­ance would be greatly appre­ci­ated. Thank you!!

 
8 Comments  comments 

forecast package v4.0

Published on 3 December 2012

A few days ago I released ver­sion 4.0 of the fore­cast pack­age for R. There were quite a few changes and new fea­tures, so I thought it deserved a new ver­sion num­ber. I keep a list of changes in the Changelog for the pack­age, but I doubt that many peo­ple look at it. So for the record, here are the most impor­tant changes to the fore­cast pack­age made since v3.0 was released.

 
22 Comments  comments 

SimpleR tips, tricks and tools

Published on 21 November 2012

I gave this talk last night to the Mel­bourne Users of R Network.

 
10 Comments  comments 

Makefiles for R/​LaTeX projects

Published on 31 October 2012

Updated: 21 Novem­ber 2012 Make is a mar­vel­lous tool used by pro­gram­mers to build soft­ware, but it can be used for much more than that. I use make when­ever I have a large project involv­ing R files and LaTeX files, which means I use it for almost all of the papers I write, and almost of the con­sult­ing reports I produce.

 
16 Comments  comments 

Why are some things easier to forecast than others?

Published on 18 September 2012

Fore­cast­ers are often met with skep­ti­cism. Almost every time I tell some­one that I work in fore­cast­ing, they say some­thing about fore­cast­ing the stock mar­ket, or fore­cast­ing the weather, usu­ally sug­gest­ing that such fore­casts are hope­lessly inac­cu­rate. In fact, fore­casts of the weather are amaz­ingly accu­rate given the com­plex­ity of the sys­tem, while any­one claim­ing to fore­cast the stock mar­ket deserves skep­ti­cism. So what is the dif­fer­ence between these two types of fore­casts, and can we say any­thing about what can be rea­son­ably be fore­cast and what can’t?

 
2 Comments  comments