Analysing Seasonal Data

Many common diseases, such as the flu and cardiovascular disease, increase markedly in winter and dip in summer. These seasonal patterns have been part of life for millennia and were first noted in ancient Greece by both Hippocrates and Herodotus. Recent interest has focused on climate change, and the concern that seasons will become more extreme with harsher winter and summer weather. We describe a set of R functions designed to model seasonal patterns in disease. We illustrate some simple descriptive and graphical methods, a more complex method that is able to model non-stationary patterns, and the case-crossover to control for seasonal confounding. In this paper we illustrate some of the functions of the season package (Barnett et al., 2012), which contains a range of functions for analysing seasonal health data. We were motivated by the great interest in seasonality found in the health literature, and the relatively small number of seasonal tools in R (or other software packages). The existing seasonal tools in R are: • the baysea function of the timsac package and the decompose and stl functions of the stats package for decomposing a time series into a trend and season; • the dynlm function of the dynlm package and the ssm function of the sspir package for fitting dynamic linear models with optional seasonal components; • the arima function of the stats package and the Arima function of the forecast package for fitting seasonal components as part of an autoregressive integrated moving average (ARIMA) model; and • the bfast package for detecting breaks in a seasonal pattern. These tools are all useful, but most concern decomposing equally spaced time series data. Our package includes models that can be applied to seasonal patterns in unequally spaced data. Such data are common in observational studies when the timing of responses cannot be controlled (e.g. for a postal survey). In the health literature much of the analysis of seasonal data uses simple methods such as com paring rates of disease by month or using a cosinor regression model, which assumes a sinusoidal seasonal pattern. We have created functions for these simple, but often very effective analyses, as we describe below. More complex seasonal analyses examine non-stationary seasonal patterns that change over time. Changing seasonal patterns in health are currently of great interest as global warming is predicted to make seasonal changes in the weather more extreme. Hence there is a need for statistical tools that can estimate whether a seasonal pattern has become more extreme over time or whether its phase has changed. Ours is also the first R package that includes the case-crossover, a useful method for controlling for seasonality. This paper illustrates just some of the functions of the season package. We show some descriptive functions that give simple means or plots, and functions whose goal is inference based on generalised linear models. The package was written as a companion to a book on seasonal analysis by Barnett and Dobson (2010), which contains further details on the statistical methods and R code.

Adrian G Barnett , Peter Baker , Annette J Dobson

CRAN packages used

season, timsac, dynlm, sspir, forecast, bfast

CRAN Task Views implied by cited packages

TimeSeries, Finance, Econometrics, Environmetrics


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Barnett, et al., "The R Journal: Analysing Seasonal Data", The R Journal, 2012

BibTeX citation

  author = {Barnett, Adrian G and Baker, Peter and Dobson, Annette J},
  title = {The R Journal: Analysing Seasonal Data},
  journal = {The R Journal},
  year = {2012},
  note = {},
  doi = {10.32614/RJ-2012-001},
  volume = {4},
  issue = {1},
  issn = {2073-4859},
  pages = {5-10}