memtiming: Influenza Epidemic Timing

View source: R/memtiming.R

memtimingR Documentation

Influenza Epidemic Timing


Function memtiming is used to find the optimal timing of an influenza epidemic in a set of weekly influenza surveillance rates. It provides the start and the end of the epidemic, also it returns a list of pre-epidemic and post-epidemic rates that can be used to calculate influenza baselines and thresholds.


memtiming(, i.n.values = 5, i.method = 2, i.param = 2.8, = T)


a numeric object (or one that can be coerced to that class).


a number, which indicates how many pre-epidemic values are taken from the pre-epidemic period.


a number from 1 to 4, to select which optimization method to use.


an optional parameter used by the method.

include information about the package in the graph.


The method to calculate the optimal timing of an epidemic is described as part of the Moving Epidemics Method (MEM), used to monitor influenza activity in a weekly surveillance system.

Input data is a vector of rates that represent a full influenza surveillance season. It can start and end at any week (tipically at week 40th), and rates can be expressed as per 100,000 inhabitants (or per consultations, if population is not available) or any other scale.

The i.n.values parameter is used to get information from the pre-epidemic and post-epidemic period. The function will extract the highest pre/post values in order to use it later to calculate other influenza indicators, such as baseline activity or threshold for influenza epidemic.

Depending of the value i.method, the function will use a different method to calculate the optimum epidemic timing.

  • 1 original method

  • 2 fixed criterium method

  • 3 slope method

  • 4 second derivative method

All methods are based upon the MAP curve, as described in the MEM Method.

The original method uses the process shown in the original paper, which describes the MEM as it was created. The fixed criterium method is an update of the MEM that uses the slope of the MAP curve fo find the optimum, which is the point where the slope is lower than a predefined value. The slope method also calculates the slope of the MAP curve, but the optimum is the one that matches the global/mean slope. The second derivative method calculates the second derivative and equals to zero to search an inflexion point in the original curve.

Two of the four methods require an additional parameter i.param: for the fixed criterium method is the predefined value to find the optimum, which typically is 2.5-3.0%, and for the original method it is needed the window parameter to smooth the map curve. A value of -1 indicates it should use to select the window parameter. See sm for more information about this topic.


memtiming returns an object of class epidemic. An object of class epidemic is a list containing at least the following components:

  • input data

  • data data with missing rates filled with data from smothing regression

  • map.curve MAP curve

  • slope.curve slope of the MAP curve

  • optimum

  • pre.epi pre-epidemic highest rates

  • epi epidemic highest rates

  • post.epi post-epidemic highest rates

  • pre-epidemic rates

  • epidemic rates

  • post-epidemic rates


Jose E. Lozano


Vega T, Lozano JE, Ortiz de Lejarazu R, Gutierrez Perez M. Modelling influenza epidemic - can we detect the beginning and predict the intensity and duration? Int Congr Ser. 2004 Jun;1263:281-3.

Vega T, Lozano JE, Meerhoff T, Snacken R, Mott J, Ortiz de Lejarazu R, et al. Influenza surveillance in Europe: establishing epidemic thresholds by the moving epidemic method. Influenza Other Respir Viruses. 2013 Jul;7(4):546-58. DOI:10.1111/j.1750-2659.2012.00422.x.

Vega T, Lozano JE, Meerhoff T, Snacken R, Beaute J, Jorgensen P, et al. Influenza surveillance in Europe: comparing intensity levels calculated using the moving epidemic method. Influenza Other Respir Viruses. 2015 Sep;9(5):234-46. DOI:10.1111/irv.12330.

Lozano JE. lozalojo/mem: Second release of the MEM R library. Zenodo [Internet]. [cited 2017 Feb 1]; Available from: DOI:10.5281/zenodo.165983


# Castilla y Leon Influenza Rates data
# Finds the timing of the first season: 2001/2002
tim <- memtiming(flucyl[1])

lozalojo/mem documentation built on July 7, 2023, 10 a.m.