Time series data in R

January 28, 2014
By

(This article was first published on Hyndsight » R, and kindly contributed to R-bloggers)

There is no shortage of time series data available on the web for use in student projects, or self-learning, or to test out new forecasting algorithms. It is now relatively easy to access these data sets directly in R.

M Competition data

The 1001 series from the M-competition and the 3003 series from the M3-competition are available as part of the Mcomp package in R.

DataMarket and Quandl

Both DataMarket and Quandl contain many thousands of time series that can be downloaded directly into R. A search for “Australian Real GDP per capita” on both sites returned many variants. The version from the Federal Reserve Bank in 2010 US dollars was available on both sites (Datamarket and Quandl). These data can be downloaded to R using the rdatamarket and Quandl packages respectively:

library(rdatamarket)
library(Quandl)
ausgdp <- as.ts(dmseries("http://data.is/1jDQwpr")[,1])
ausgdp2 <- ts(rev(Quandl("FRED/AUSRGDPC", type="ts")), end=2011)

The two series should be identical. For some bizarre reason, the Quandl data comes in reverse time order so rev needs to be used, and then the time series attributes applied. The Quandl function will also generate a warning that no authentication token has been used. Unauthenticated users are limited to 50 downloads per day. See the help page for details.

The dmseries function from the rdatamarket package is simpler to use. The short URL is provided on the “Export” tab of the page for the data set on Datamarket. The data come in zoo format, but can easily be converted to a ts object using as.ts.

TSDL

For many years, I maintained the Time Series Data Library consisting of about 800 time series including many from well-known textbooks. These were transferred to DataMarket in June 2012 and are now available here.

R packages

A number of other R packages contain time series data. The following packages are listed in the Time Series Analysis Task View

  • Data from Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications are provided in the fma package.
  • Data from Hyndman, Koehler, Ord and Snyder (2008) Forecasting with exponential smoothing are in the expsmooth package.
  • Data from Hyndman and Athanasopoulos (2013) Forecasting: principles and practice are in the fpp package.
  • Data from Cryer and Chan (2010) Time series analysis with applications in R are in the TSA package.
  • Data from Shumway and Stoffer (2011) Time series analysis and its applications are in the astsa package.
  • Data from Tsay (2005) Analysis of financial time series are in the FinTS package, along with some functions and script files required to work some of the examples.
  • TSdbi provides a common interface to time series databases.
  • fame provides an interface for FAME time series databases
  • AER and Ecdat both contain many data sets (including time series data) from many econometrics text books

To leave a comment for the author, please follow the link and comment on his blog: Hyndsight » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.