Trends seasonality and anomalies making your timeseries talk

  • Slides: 67
Download presentation
Trends, seasonality and anomalies: making your time-series talk Wladimir J. Alonso Fogarty International Center

Trends, seasonality and anomalies: making your time-series talk Wladimir J. Alonso Fogarty International Center / NIH

Goals for of this talk 1. Learn how to extract the basic components of

Goals for of this talk 1. Learn how to extract the basic components of epidemiological relevance from a time-series 2. Learn how to explore the spatial patterns of those components 3. Introduce the modeling tool Epipoi (www. epipoi. info)

But before this…

But before this…

A parenthesis for “Graphical Excellence” • well-designed presentation of interesting data – a matter

A parenthesis for “Graphical Excellence” • well-designed presentation of interesting data – a matter of substance, statistics and design • consists of complex ideas communicated with clarity, precision and efficiency • is nearly always multivariate • requires telling the truth about the data • Provides the viewer with the greatest number of ideas in the shortest time with the least ink in the smallest space Edward Tufte (1983)

Napoleon's Retreat from Moscow, 1812 by Illarion Pryanishnikov

Napoleon's Retreat from Moscow, 1812 by Illarion Pryanishnikov

Charles Joseph Minard (1861): Losses suffered by Napoleon's army in the Russian campaign of

Charles Joseph Minard (1861): Losses suffered by Napoleon's army in the Russian campaign of 1812 "It may well be the best statistical graphic ever drawn“ (Edward R. Turfte, 1983)

First: Organize your dataset in a meaningful way A typical mortality dataset

First: Organize your dataset in a meaningful way A typical mortality dataset

Structured spreadsheet as a source of instantaneous analysis Time in a meaningful sequence Variables

Structured spreadsheet as a source of instantaneous analysis Time in a meaningful sequence Variables in meaningful sequence - Age groups - Causes of deaths - Longitude - Latitude…

So you can plot in this way: Trends, anomalies, seasonality and even spatial can

So you can plot in this way: Trends, anomalies, seasonality and even spatial can be seen Alonso et al 2011 Spatio-temporal patterns of diarrhoeal mortality in Mexico. Epidemiol. Infect

We can use this display to see the shift in the timing of RSV

We can use this display to see the shift in the timing of RSV circulation in São Paulo city and its implications for immunoprophylaxis period of palivizumabe prophylaxis Paiva et al 2012 JMV

And then we can use a different plot for displaying the epidemiologic and putative

And then we can use a different plot for displaying the epidemiologic and putative explanatory series Paiva et al 2012 JMV

In fact, sometimes a simple organization of data in space can generate all the

In fact, sometimes a simple organization of data in space can generate all the information we need! This is a quick example on how we found that (surprisingly!) the Northern hemisphere timing of the vaccine would be more efficient than the current Southern timing for Brazil Mello et al 2010 PLo. S One

Influenza virus isolated plotted exactly in their time of collection influenza viruses isolated monthly

Influenza virus isolated plotted exactly in their time of collection influenza viruses isolated monthly from 1999 to 2007 in Belém and São Paulo Belém São Paulo Mello et al (2010)

Now we overlap the Southern and Northern Hemisphere recommendations

Now we overlap the Southern and Northern Hemisphere recommendations

And count first the matches obtained with the Southern Hemisphere recommendation… 11 matches

And count first the matches obtained with the Southern Hemisphere recommendation… 11 matches

And compare with the matches if the Northern Hemisphere timing of the vaccine and

And compare with the matches if the Northern Hemisphere timing of the vaccine and composition were applied 24 matches!

connecting analytical, visual, and interactive methods • Visual–interactive methods are very promising in integrating

connecting analytical, visual, and interactive methods • Visual–interactive methods are very promising in integrating analytical methods with human experts and real-world workflows to achieve … • http: //www. pnas. org/content/109/29/11472. long

 • It is a valuable tool forecaters in any discipline— a visual inspection

• It is a valuable tool forecaters in any discipline— a visual inspection of a graphic showing the interaction between two variables is often a quicker and more reliable way to detect outliers in your data than a statistical test. It’s also one of those areas where computers lag well behind the human brain • Silver, Nate (2012). The Signal and the Noise: The Art and Science of Prediction Penguin Books Ltd. Kindle Edition.

Part 1: How to extract the basic components of epidemiological relevance from a time-series?

Part 1: How to extract the basic components of epidemiological relevance from a time-series?

Brazilian dataset of deaths coded as pneumonia and influenza We are going to extract

Brazilian dataset of deaths coded as pneumonia and influenza We are going to extract as much information as possible from this series

Brazilian dataset of deaths coded as pneumonia and influenza • Example of analyses performed

Brazilian dataset of deaths coded as pneumonia and influenza • Example of analyses performed in Schuck-Paim et al 2012 Were equatorial regions less affected by the 2009 influenza pandemic? The Brazilian experience. PLo. S One. • Data source: Department of Vital Statistics from the Brazilian Ministry of Health

Series to be analyzed Typical epidemiological time series from where to obtain as many

Series to be analyzed Typical epidemiological time series from where to obtain as many meaningful and useful parameters as possible

Average mortality at time t Many times this information is all we need!

Average mortality at time t Many times this information is all we need!

Average mortality at time t But, it still leaves much of the variation (“residuals”)

Average mortality at time t But, it still leaves much of the variation (“residuals”) of the series unexplained … the first of which seems to be an “unbalanced” between the extremities

Linear trend • Better now!

Linear trend • Better now!

Trend (linear) Mortality at time t Mean Mortality We can use this information (e.

Trend (linear) Mortality at time t Mean Mortality We can use this information (e. g. is the disease increasing/decreasing? but then the data needs to be incidence) Linear trends

Trend (with quadratic term too) • Better definition • It gets more complicated as

Trend (with quadratic term too) • Better definition • It gets more complicated as a parameter to be compared across time-series • But better if our purpose is eliminate the temporal trend Mortality at time t Quadratic trends

Getting rid of the trend Blue line: “detrended series”

Getting rid of the trend Blue line: “detrended series”

But let’s keep the graphic of the original series for illustrative purposes Mortality at

But let’s keep the graphic of the original series for illustrative purposes Mortality at time t Mean Mortality Clearly, there are still other interesting epidemiological patterns to describe… Linear and quadratic trends

We can see some rhythm… Mortality at time t Mean Mortality • The block

We can see some rhythm… Mortality at time t Mean Mortality • The block of residuals alternates cyclically • Therefore this is something that can be quantified using few parameters Linear and quadratic trends

Jean Baptiste Joseph Fourier (1768 – 1830)

Jean Baptiste Joseph Fourier (1768 – 1830)

The Fourier theorem states that any waveform can be duplicated by the superposition of

The Fourier theorem states that any waveform can be duplicated by the superposition of a series of sine and cosine waves As an example, the following Fourier expansion of sine waves provides an approximation of a square wave Source: http: //www. files. chem. vt. edu/chem-ed/data/fourier. html

Fourier decomposition • the periodic variability of the monthly mortality timeseries is partitioned into

Fourier decomposition • the periodic variability of the monthly mortality timeseries is partitioned into harmonic functions. • By summing the harmonics we obtain what can be considered as an average seasonal signature of the original series, where year-to-year variations are removed but seasonal variations within the year are preserved • This method is not always appropriate when dealing with complex population time series, since it cannot take into account the often-observed changes in the periodic behavior of such series (i. e. , they are not “stationary”).

Before modeling cycles: Mortality at time t Mean Mortality …so, remembering, these are the

Before modeling cycles: Mortality at time t Mean Mortality …so, remembering, these are the residuals before Fourier Linear and quadratic trends

… and now with the incorporation of the annual harmonic Mortality at time t

… and now with the incorporation of the annual harmonic Mortality at time t Mean Mortality Annual harmonic trends

or with the semi-annual harmonic only? Mortality at time t Mean Mortality semiannual harmonic

or with the semi-annual harmonic only? Mortality at time t Mean Mortality semiannual harmonic trends

Much better when the annual + semi-annual harmonics are considered together! Mortality at time

Much better when the annual + semi-annual harmonics are considered together! Mortality at time t Mean Mortality Annual and semi-annual harmonics trends

Although not much difference when the quarterly harmonic is added… Mortality at time t

Although not much difference when the quarterly harmonic is added… Mortality at time t Mean Mortality Periodic (seasonal) components trends

average seasonal signature of the original series • We obtained therefore the average seasonal

average seasonal signature of the original series • We obtained therefore the average seasonal signature of the original series (where year-toyear variations are removed but seasonal variations within the year are preserved) • Now, let’s extract some interest parameters (remember, we always need a “number” to compare, for instance, across different sites)

Timing and Amplitude average seasonal signature of the original series

Timing and Amplitude average seasonal signature of the original series

Variations in relative peak amplitude of pneumonia and influenza coded deaths with latitude Alonso

Variations in relative peak amplitude of pneumonia and influenza coded deaths with latitude Alonso et al 2007 Seasonality of influenza in Brazil: a traveling wave from the Amazon to the subtropics. Am J Epidemiol 5 0 Latitude (degrees) -5 -10 -15 -20 (p < 0. 001) -25 -30 -35 0 10 20 30 40 50 60 70 Amplitude of the major peak (%) 80 90

The seasonal component was found to be most intense in southern states, gradually attenuating

The seasonal component was found to be most intense in southern states, gradually attenuating towards central states (15 o. S) and remained low near the Equator 5 0 Latitude (degrees) -5 -10 -15 -20 (p < 0. 001) -25 -30 -35 0 10 20 30 40 50 60 70 Amplitude of the major peak (%) 80 90

Variations in peak timing of influenza with latitude 5 (p < 0. 001) 0

Variations in peak timing of influenza with latitude 5 (p < 0. 001) 0 Latitude (degrees) -5 -10 -15 -20 -25 -30 -35 J F M A M J J A S O N D Phase of the major peak (months of the year)

Peak timing was found to be structured spatio-temporally: annual peaks were earlier in the

Peak timing was found to be structured spatio-temporally: annual peaks were earlier in the north, and gradually later towards the south of Brazil 5 (p < 0. 001) 0 Latitude (degrees) -5 -10 -15 -20 -25 -30 -35 J F M A M J J A S O N D Phase of the major peak (months of the year)

Such results suggest southward waves of influenza across Brazil, originating from equatorial and low

Such results suggest southward waves of influenza across Brazil, originating from equatorial and low population regions and moving towards temperate and highly populous regions in ~3 months. 5 (p < 0. 001) 0 Latitude (degrees) -5 -10 -15 -20 -25 -30 -35 J F M A M J J A S O N D Phase of the major peak (months of the year)

But can we still improve the model? Yes, and in some cases we should,

But can we still improve the model? Yes, and in some cases we should, Mostly to model excess estimates e. g. pandemic year Mortality at time t Mean Mortality Periodic (seasonal) components trends

Residuals after excluding “atypical” (i. e. pandemic) years from the model To define what

Residuals after excluding “atypical” (i. e. pandemic) years from the model To define what is “normal” it is necessary to exclude the year that we suspect might be ‘abnormal’ from the model

Ok, so now we can count what was the impact of the pandemic here

Ok, so now we can count what was the impact of the pandemic here right?

No! (unless you consider all the other anomalies pandemics (and anti-pandemics…) That is why

No! (unless you consider all the other anomalies pandemics (and anti-pandemics…) That is why we need to include usual residual variance in the model, and calculate excess BEYOND usual variation

Residuals after modeling year to year variance (1. 96 SD above model) Mortality at

Residuals after modeling year to year variance (1. 96 SD above model) Mortality at time t Mean Mortality Periodic (seasonal) components trends error term

This is a measure of excess that is much closer to the real impact

This is a measure of excess that is much closer to the real impact of the pandemic

Geographical patterns in the severity of pandemic mortality in a large latitudinal range Schuck-Paim

Geographical patterns in the severity of pandemic mortality in a large latitudinal range Schuck-Paim et al 2012 PLo. S One

Program available at www. epipoi. info Paper explaing the program available at http: //www.

Program available at www. epipoi. info Paper explaing the program available at http: //www. biomedcentral. com/content/pdf/1471 -2458 -12 -982. pdf

Example from diarrhea mortality in Mexico (1979 -1988) Alonso WJ et al Spatio-temporal patterns

Example from diarrhea mortality in Mexico (1979 -1988) Alonso WJ et al Spatio-temporal patterns of diarrhoeal mortality in Mexico. Epidemiol Infect 2011 Apr; 1 -9.

quantitative and qualitative change of diarrhea in Mexico 1917 -2001 Summer peaks Winter peaks

quantitative and qualitative change of diarrhea in Mexico 1917 -2001 Summer peaks Winter peaks Gutierrez et al. Impact of oral rehydration and selected public health interventions on reduction of mortality from childhood diarrhoeal diseases in Mexico. Bulletin of the WHO 1996 Velazquez et al. Diarrhea morbidity and mortality in Mexican children : impact of rotavirus disease. Pediatric Infectious Disease Journal 2004 Villa et al. Seasonal diarrhoeal mortality among Mexican children. Bulletin of the WHO 1999

State-specific rates, sorted by the latitude of their capitals, from north to south (y

State-specific rates, sorted by the latitude of their capitals, from north to south (y axis)

Timing of annual peaks (1979 -1988) First peak in the Mexican capital !

Timing of annual peaks (1979 -1988) First peak in the Mexican capital !

Major Annual Peaks of diarrhea of the period 19791988 in Mexican states, sorted by

Major Annual Peaks of diarrhea of the period 19791988 in Mexican states, sorted by their latitude

Climatologic factors Monthly climatic data were obtained from worldwide climate maps generated by the

Climatologic factors Monthly climatic data were obtained from worldwide climate maps generated by the interpolation of climatic information from groundbased meteorological stations Mitchell TD, Jones PD. An improved method of constructing a database of monthly climate observations and associated high-resolution grids. International Journal of Climatology 2005; 25: 693 -712. (data at: http: //www. cru. uea. ac. uk/cru/data/hrg/)

Early peaks in spring in the central region of Mexico (where most of the

Early peaks in spring in the central region of Mexico (where most of the people lives) followed by a decrease in summer

Early peaks in the monthly average maximum temperature in the central region of Mexico

Early peaks in the monthly average maximum temperature in the central region of Mexico followed by a decrease in summer too !

The same climatic factors that enabled a dense and ancient human occupation in the

The same climatic factors that enabled a dense and ancient human occupation in the central part of Mexico prevent a strong presence of bacterial diarrhea and the observed early peaks: Mild summers - with average maximum temperatures below 24 o. C

Thanks! wladimir. alonso@nih. gov

Thanks! wladimir. alonso@nih. gov