Learn R Programming

The Moving Epidemic Method R Package

Overview

The Moving Epidemics Method MEM is a tool developed in the Health Sentinel Network of Castilla y León (Spain) to help in the routine influenza surveillance in health systems. It gives a better understanding of the annual influenza epidemics and allows the weekly assessment of the epidemic status and intensity.

Although in its conception it was originally created to be used with influenza data and health sentinel networks, MEM has been tested with different respiratory infectious diseases and surveillance systems so nowadays it could be used with any parameter which present a seasonal accumulation of cases that can be considered an epidemic.

MEM development started in 2001 and the first record appeared in 2003 in the Options for the Control of Influenza V. It was presented to the baselines working group of the European Influenza Surveillance Scheme (EISS) in the 12th EISS Annual Meeting (Malaga, Spain, 2007), with whom started a collaboration that continued when, in 2008, was established the European Influenza Surveillance Network.

In 2009 MEM is referenced in an official European document: the Who European guidance for influenza surveillance in humans. A year later MEM was implemented in The European Surveillance System (TESSy), of the European Centre for Disease Prevention and Control (ECDC), and in 2012, after a year piloting, in the EuroFlu regional influenza surveillance platform, of the World Health Organization Regional Office for Europe (WHO-E).

As a result of the collaboration with ECDC and WHO-E, two papers have been published, one related to the establishment of epidemic thresholds and other to the comparison of intensity levels in Europe.

Installation

The stable package can be installed from the official R repositories (CRAN) using the built-in install function (or from the package manager in some GUIs for R):

# install the memapp CRAN version
install.packages("mem")

Or from the official repository:

if(!require("devtools")) install.packages("devtools")
library("devtools")
# install the mem stable version from GitHub
install_github("lozalojo/mem", ref = "master")

To install the development version of mem use the devtools package.

if(!require("devtools")) install.packages("devtools")
library("devtools")
# install the memapp development version from GitHub
install_github("lozalojo/mem", ref = "development")

Web application

There is a package that acts as a Graphical User Interface (GUI) for mem. The package is called memapp, you can find more information on the official repository:

memapp repository

Usage

# load the library
library("mem")

# run the help
help("mem")

References

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: https://zenodo.org/record/165983.

Lozano JE. lozalojo/memapp: Second release of the MEM Shiny Web Application R package. Zenodo [Internet]. [cited 2018 Feb 15]; Available from: https://zenodo.org/record/1173518.

Copy Link

Version

Install

install.packages('mem')

Monthly Downloads

525

Version

2.19

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Lozano Jose E.

Last Published

July 25th, 2025

Functions in mem (2.19)

get.dates

create epidemiological calendar
extraer.datos.optimo.map

Extract optimum
maxnvalores

highest n values of a data set, removing Inf and -Inf
mem-package

mem: The Moving Epidemic Method
iconfianza.aritmetica

confidence interval for the arithmetic mean using the normal approximation
iconfianza

generic confidence interval calculation function
iconfianza.percentil.kc

confidence interval por the median using KC Method
iconfianza.percentil.boot

confidence interval por the median using bootstrap methods
get.epiweek

create epidemiological calendar
memintensity

Thresholds for influenza intensity
memmodel

Methods for influenza modelization
maxFixNA

max function, removing Inf and -Inf
memsurveillance

Creates the surveillance graph of the current season
full.series.graph

Creates the historical series graph of the datasets
flucylraw

Castilla y Leon influenza standarised rates
memstability

Stability of indicators
iconfianza.percentil.eqnpar

confidence interval por the median using KC Method
optimal.tickmarks

Find tickmarks for a given range of the y-axis that best fit an optimal number of tickmarks you decide. f.i: what if i want to have a graph with 8 tickmarks in a range of 34 to 345
normalizar

standarize data to [0,1] interval
memsurveillance.animated

Creates the animated graph of the surveillance of the current season
suavizado

smoothing regression function
memtiming

Influenza Epidemic Timing
iconfianza.logx

confidence interval for a point (using log transformation and geometric mean)
iconfianza.x

confidence interval for a point (using arithmetic mean)
minFixNA

min function, removing Inf and -Inf
memtrend

Methods for influenza trend calculation
transformdata

Data transformation
roc.analysis

Analysis of different indicators to find the optimum value of the window parameter
transformseries.multiple

divide a series in parts
transformseries.moving.average

moving average transformation
percentage.added

For use with transformseries.multiple
transformseries.loess

loess transformation
processPlots

Full process plots for mem
minnvalores

lowest n values of a data set, removing Inf and -Inf
transformseries.odd

odd transformation
missings.inside

returns position of missing values inside the season. Leading and trailing missing values are not considered.
optimum.by.inspection

Inspection calcultation of the optimum
output.ci

function to format output
semana.absoluta

Transforms relative weeks to absolute weeks in a 1-52 normal season
iconfianza.completo

Int. Confianza de 2 y 1 cola, por encima y por debajo. De la media y el punto.
iconfianza.geometrica

confidence interval for the geometric mean using the log-normal approximation
memevolution

Evolution of estimators
transformseries

Transformation of series of data
transformseries.spline

spline transformation
transformseries.twowaves

adjust a mixed model of two normal distributions
memgoodness

Goodness of fit of the mem
transformdata.back

Data transformation
calcular.optimo.derivada

calculates optimum: second derivative equals 0 (change signs from - to +, or + to -)
calcular.optimo.original

calculates optimum: original method: second derivative + axis change
calcular.map

calculates map curve
flucyl

Castilla y Leon influenza crude rates
calcular.optimo.pendiente

calculates optimum: slope matches the overall slope
comparar.metodos

Compares outputs from two methods of locating the epidemic
add.alpha

Add an alpha value to a colour http://www.magesblog.com/2013/04/how-to-change-alpha-value-of-colours-in.html
calcular.optimo

calculates optimum generic function
create.calendar

create epidemiological calendar
epimem

Deprecated function(s) in the mem package
calcular.indicadores.2.timings

Calculates specificity and sensitivity
extraer.datos.epi

Extract epidemic hightest rates
extraer.datos.pre.epi

Extract pre-epidemic hightest rates
calcular.optimo.criterio

calculates optimum: fixed criteria for slope
calcular.indicadores

Calculates specificity and sensitivity
extraer.datos.post.epi

Extract post-epidemic hightest rates
epitiming

Deprecated function(s) in the mem package
fill.missing

fills in missing values inside the season with smoothing regression
extraer.datos.curva.map

Extract map curve