A blog by Rob J Hyndman 

Twitter Gplus RSS

Posts Tagged ‘computing’:


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 

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 

LaTeX loops

Published on 23 October 2012

Today I was writ­ing a report which included 20 fig­ures, with the names demandplot1.pdf, demandplot2.pdf, …, demandplot20.pdf, and all with sim­i­lar cap­tions. Clearly a loop was required. After all, LaTeX is a pro­gram­ming lan­guage, so we should be able to take advan­tage of its capabilities.

 
2 Comments  comments 

COMPSTAT2012

Published on 28 August 2012

This week I’m in Cyprus attend­ing the COMPSTAT2012 con­fer­ence. There’s been the usual inter­est­ing col­lec­tion of talks, and inter­ac­tions with other researchers. But I was struck by two side com­ments in talks this morn­ing that I’d like to men­tion. Stephen Pol­lock: Don’t imag­ine your model is the truth Actu­ally, Stephen said some­thing like “econ­o­mists (or was it econo­me­tri­cians?) have a bad habit of imag­in­ing their mod­els are true”. He gave the exam­ple of peo­ple ask­ing whether GDP “has a unit root”? GDP is an eco­nomic mea­sure­ment. It no more has a unit root than I do. But the mod­els used to approx­i­mate the dynam­ics of GDP may have a unit root. This is an exam­ple of con­fus­ing your data with your model. Or to put it the other way around, imag­in­ing that the model is true rather than an approx­i­ma­tion. A related thing that tends to annoy me is to refer to the model as the “data gen­er­at­ing process”. No model is a data gen­er­at­ing process, unless the data were obtained by sim­u­la­tion from the model. Mod­els are only ever approx­i­ma­tions, and imag­in­ing that they are data gen­er­at­ing processes only leads to over-​​​​confidence and bad sci­ence. Matías Salibián-​​​​Barrera: Make all your code pub­lic After giv­ing an inter­est­ing sur­vey of

(More)…

 
1 Comment  comments