| Title: | Antimicrobial Resistance Surveillance, Epidemiology and Risk Analysis |
| Version: | 0.1.0 |
| Description: | Provides tools for antimicrobial resistance surveillance, epidemiological analysis, temporal trend detection, early warning detection, spatial cluster identification, and risk factor analysis. The package supports analysis of antimicrobial resistance patterns, resistance to multiple antimicrobial classes, temporal surveillance, and spatial epidemiology for applications in veterinary, medical, and One Health research. Antimicrobial resistance surveillance approaches are informed by guidelines from WHO (2023) https://www.who.int/publications/i/item/9789240076600 and WOAH (2024) https://www.woah.org/fileadmin/Home/eng/Health_standards/tahc/2024/en_chapitre_antibio_harmonisation.htm. Statistical methods include cumulative sum (CUSUM) monitoring (Page, 1954) <doi:10.1093/biomet/41.1-2.100>, exponentially weighted moving average (EWMA) monitoring (Roberts, 1959) <doi:10.1080/00401706.1959.10489860>, Local Moran's I spatial analysis (Anselin, 1995) <doi:10.1111/j.1538-4632.1995.tb00338.x>, and multidrug- and extensively drug-resistant classification (Magiorakos et al., 2012) <doi:10.1111/j.1469-0691.2011.03570.x>. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr, ggplot2, rlang, sf, spdep, stats |
| Suggests: | covr, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| LazyData: | true |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-02 23:47:39 UTC; m |
| Author: | Vinodhkumar Obli Rajendran [aut, cre], Keerthi Aaradhana [aut] |
| Maintainer: | Vinodhkumar Obli Rajendran <vinodhkumar.rajendran@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-12 13:30:24 UTC |
Generate AMR surveillance alerts
Description
Combines EWMA and CUSUM surveillance signals.
Usage
amr_alert(x, lambda = 0.2, L = 3, h = 5)
Arguments
x |
Numeric vector of resistance proportions. |
lambda |
EWMA smoothing parameter. |
L |
EWMA control-limit multiplier. |
h |
CUSUM decision interval. |
Value
A data frame containing EWMA, CUSUM and combined alerts.
Detect AMR changes using CUSUM
Description
Calculates a one-sided cumulative sum for increases in resistance.
Usage
amr_cusum(x, target = mean(x), k = 0, h = 5)
Arguments
x |
Numeric vector of resistance proportions. |
target |
Target resistance proportion. |
k |
Reference value. |
h |
Decision interval. |
Value
A data frame containing the cumulative sum and alert status.
Detect antimicrobial resistance changes using EWMA
Description
Applies an exponentially weighted moving average to a time series of resistance proportions.
Usage
amr_ewma(x, lambda = 0.2, L = 3)
Arguments
x |
Numeric vector of resistance proportions. |
lambda |
EWMA smoothing parameter. |
L |
Control-limit multiplier. |
Value
A data frame containing the observed values, EWMA statistic, and upper/lower control limits.
Examples
x <- c(
0.20, 0.21, 0.19, 0.22,
0.23, 0.25, 0.40, 0.45
)
amr_ewma(x)
Example antimicrobial resistance surveillance dataset
Description
A simulated dataset containing antimicrobial susceptibility results, sampling dates, and bacterial species for demonstrating functions in AMRsurveilR.
Usage
amr_example
Format
A data frame with 200 rows and 8 columns:
- isolate_id
Unique isolate identifier.
- date
Date of isolate collection.
- organism
Bacterial species.
- AMP
Ampicillin susceptibility result.
- TET
Tetracycline susceptibility result.
- CIP
Ciprofloxacin susceptibility result.
- GEN
Gentamicin susceptibility result.
- CTX
Cefotaxime susceptibility result.
Details
The dataset is simulated and is provided solely for examples,
testing, and demonstration. Susceptibility results are coded as
"R" for resistant and "S" for susceptible.
Source
Simulated data generated for the AMRsurveilR package.
Detect spatial hotspots of antimicrobial resistance
Description
Identifies statistically significant spatial clusters of antimicrobial resistance using Local Moran's I (LISA).
Usage
amr_hotspot(
data,
geometry,
variable,
queen = TRUE,
p_value = 0.05,
zero.policy = TRUE
)
Arguments
data |
A data frame containing the AMR variable. |
geometry |
An |
variable |
Name of the numeric AMR variable as a character string. |
queen |
Logical. Should queen contiguity be used for polygon
neighbours? Default is |
p_value |
Significance level for hotspot classification. Default is 0.05. |
zero.policy |
Logical. Should observations with no neighbours
be allowed? Default is |
Details
The function classifies observations into:
High-High: high AMR surrounded by high AMR
Low-Low: low AMR surrounded by low AMR
High-Low: high AMR surrounded by low AMR
Low-High: low AMR surrounded by high AMR
Not significant
The function uses spatial neighbours generated from the supplied
sf geometry and calculates Local Moran's I using spdep::localmoran().
The AMR variable is standardized before calculating the spatial
clusters.
Value
A data frame containing the original AMR values, Local Moran's I, expected value, variance, Z-score, p-value, and cluster classification.
Examples
library(sf)
# Create example AMR data
amr_data <- data.frame(
amr_prevalence = c(
0.10, 0.20, 0.80,
0.15, 0.75, 0.85,
0.20, 0.70, 0.90
)
)
# Create a 3 x 3 grid of neighbouring polygons
polygons <- lapply(0:8, function(i) {
x <- i %% 3
y <- i %/% 3
st_polygon(list(matrix(
c(
x, y,
x + 1, y,
x + 1, y + 1,
x, y + 1,
x, y
),
ncol = 2,
byrow = TRUE
)))
})
district_sf <- st_sf(
geometry = st_sfc(polygons)
)
hotspots <- amr_hotspot(
data = amr_data,
geometry = district_sf,
variable = "amr_prevalence"
)
head(hotspots)
Fit logistic regression for AMR risk factors
Description
Fits a binomial logistic regression model.
Usage
amr_logistic(data, formula)
Arguments
data |
A data frame. |
formula |
A model formula. |
Value
A fitted glm object.
Examples
dat <- data.frame(
MDR = c(0, 1, 0, 1, 1, 0),
antibiotic_use = c(0, 1, 0, 1, 1, 0),
farm_size = c(10, 20, 12, 30, 25, 15)
)
amr_logistic(
dat,
MDR ~ antibiotic_use + farm_size
)
Identify multidrug-resistant isolates
Description
Identifies isolates resistant to at least a specified number of antimicrobial agents.
Usage
amr_mdr(
data,
antibiotic_columns,
isolate_id = NULL,
resistant_value = "R",
min_classes = 3
)
Arguments
data |
A data frame. |
antibiotic_columns |
Character vector of antimicrobial columns. |
isolate_id |
Optional isolate identifier column. |
resistant_value |
Value representing resistance. |
min_classes |
Minimum number of resistant antimicrobial agents. |
Value
A data frame containing the number of resistant antimicrobials and MDR classification.
Examples
dat <- data.frame(
isolate = 1:3,
AMP = c("R", "S", "R"),
TET = c("R", "S", "S"),
CIP = c("S", "S", "R")
)
amr_mdr(
dat,
c("AMP", "TET", "CIP"),
isolate_id = "isolate"
)
Calculate antimicrobial resistance prevalence
Description
Calculates the proportion of resistant isolates and its binomial confidence interval.
Usage
amr_prevalence(resistant, total, conf.level = 0.95, method = "exact")
Arguments
resistant |
Number of resistant isolates. |
total |
Total number of isolates tested. |
conf.level |
Confidence level. Default is 0.95. |
method |
Confidence interval method passed to |
Value
A data frame containing resistant isolates, total isolates, prevalence, lower and upper confidence limits.
Examples
amr_prevalence(42, 100)
Calculate antimicrobial resistance profile
Description
Calculates resistance prevalence for multiple antimicrobial agents.
Usage
amr_resistance_profile(data, antibiotic_columns, resistant_value = "R")
Arguments
data |
A data frame. |
antibiotic_columns |
Character vector containing antibiotic columns. |
resistant_value |
Value representing resistance, usually |
Value
A data frame containing the number tested, resistant isolates, and resistance percentage for each antimicrobial.
Examples
data <- data.frame(
AMP = c("R", "S", "R", "S"),
TET = c("S", "R", "R", "S")
)
amr_resistance_profile(
data,
c("AMP", "TET")
)
Calculate temporal antimicrobial resistance trends
Description
Aggregates antimicrobial resistance observations by a specified time period and calculates the proportion of resistant isolates.
Usage
amr_trend(data, date, outcome, resistant_value = "R", period = "month")
Arguments
data |
A data frame. |
date |
Column containing dates. |
outcome |
Column containing antimicrobial susceptibility results. |
resistant_value |
Value representing resistance. Default is |
period |
Aggregation period. One of |
Value
A data frame containing the time period, number tested, number resistant, and resistance percentage.
Examples
data(amr_example)
trend <- amr_trend(
data = amr_example,
date = date,
outcome = AMP
)
head(trend)
Identify extensively drug-resistant isolates
Description
A simple threshold-based implementation. The definition should be adapted to the organism and antimicrobial-class framework used in the study.
Usage
amr_xdr(data, antibiotic_columns, resistant_value = "R", min_resistant = 5)
Arguments
data |
A data frame. |
antibiotic_columns |
Character vector of antimicrobial columns. |
resistant_value |
Value representing resistance. |
min_resistant |
Minimum number of resistant agents. |
Value
A data frame with resistant counts and XDR classification.
Plot antimicrobial resistance trend
Description
Produces a temporal antimicrobial resistance trend plot.
Usage
plot_amr_trend(x, title = "Antimicrobial Resistance Trend")
Arguments
x |
A data frame returned by |
title |
Plot title. |
Value
A ggplot object.
Examples
data(amr_example)
trend <- amr_trend(
data = amr_example,
date = date,
outcome = AMP
)
plot_amr_trend(trend)