1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 12:06:14 +01:00
AMR/man/resistance_predict.Rd

177 lines
7.2 KiB
Plaintext
Raw Normal View History

2018-02-21 11:52:31 +01:00
% Generated by roxygen2: do not edit by hand
2018-08-10 15:01:05 +02:00
% Please edit documentation in R/resistance_predict.R
2018-07-13 17:23:46 +02:00
\name{resistance_predict}
\alias{resistance_predict}
2023-01-21 23:47:20 +01:00
\alias{sir_predict}
2019-01-15 12:45:24 +01:00
\alias{plot.resistance_predict}
2023-01-21 23:47:20 +01:00
\alias{ggplot_sir_predict}
\alias{autoplot.resistance_predict}
2021-07-12 20:24:49 +02:00
\title{Predict Antimicrobial Resistance}
2018-02-21 11:52:31 +01:00
\usage{
resistance_predict(
x,
col_ab,
col_date = NULL,
year_min = NULL,
year_max = NULL,
year_every = 1,
minimum = 30,
model = NULL,
I_as_S = TRUE,
preserve_measurements = TRUE,
info = interactive(),
...
)
2023-01-21 23:47:20 +01:00
sir_predict(
x,
col_ab,
col_date = NULL,
year_min = NULL,
year_max = NULL,
year_every = 1,
minimum = 30,
model = NULL,
I_as_S = TRUE,
preserve_measurements = TRUE,
info = interactive(),
...
)
\method{plot}{resistance_predict}(x, main = paste("Resistance Prediction of", x_name), ...)
2023-01-21 23:47:20 +01:00
ggplot_sir_predict(
x,
main = paste("Resistance Prediction of", x_name),
ribbon = TRUE,
...
)
\method{autoplot}{resistance_predict}(
2021-07-12 20:24:49 +02:00
object,
main = paste("Resistance Prediction of", x_name),
ribbon = TRUE,
...
)
2018-02-21 11:52:31 +01:00
}
\arguments{
\item{x}{a \link{data.frame} containing isolates. Can be left blank for automatic determination, see \emph{Examples}.}
2019-05-13 16:35:48 +02:00
\item{col_ab}{column name of \code{x} containing antimicrobial interpretations (\code{"R"}, \code{"I"} and \code{"S"})}
2018-02-21 11:52:31 +01:00
\item{col_date}{column name of the date, will be used to calculate years if this column doesn't consist of years already - the default is the first column of with a date class}
2018-02-21 11:52:31 +01:00
2019-01-12 19:31:30 +01:00
\item{year_min}{lowest year to use in the prediction model, dafaults to the lowest year in \code{col_date}}
2018-07-26 16:30:42 +02:00
\item{year_max}{highest year to use in the prediction model - the default is 10 years after today}
2018-02-21 11:52:31 +01:00
\item{year_every}{unit of sequence between lowest year found in the data and \code{year_max}}
2018-07-26 16:30:42 +02:00
\item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.}
\item{model}{the statistical model of choice. This could be a generalised linear regression model with binomial distribution (i.e. using \code{glm(..., family = binomial)}, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See \emph{Details} for all valid options.}
2018-02-21 11:52:31 +01:00
2021-05-12 18:15:03 +02:00
\item{I_as_S}{a \link{logical} to indicate whether values \code{"I"} should be treated as \code{"S"} (will otherwise be treated as \code{"R"}). The default, \code{TRUE}, follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section \emph{Interpretation of S, I and R} below.}
2018-02-21 11:52:31 +01:00
2021-05-12 18:15:03 +02:00
\item{preserve_measurements}{a \link{logical} to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}.}
2018-02-21 11:52:31 +01:00
2021-05-12 18:15:03 +02:00
\item{info}{a \link{logical} to indicate whether textual analysis should be printed with the name and \code{\link[=summary]{summary()}} of the statistical model.}
2019-01-15 12:45:24 +01:00
2020-12-22 00:51:17 +01:00
\item{...}{arguments passed on to functions}
2019-01-15 12:45:24 +01:00
2019-01-15 16:38:54 +01:00
\item{main}{title of the plot}
2021-05-12 18:15:03 +02:00
\item{ribbon}{a \link{logical} to indicate whether a ribbon should be shown (default) or error bars}
2021-07-12 22:12:28 +02:00
\item{object}{model data to be plotted}
2018-02-21 11:52:31 +01:00
}
\value{
A \link{data.frame} with extra class \code{\link{resistance_predict}} with columns:
2018-07-26 16:30:42 +02:00
\itemize{
\item \code{year}
\item \code{value}, the same as \code{estimated} when \code{preserve_measurements = FALSE}, and a combination of \code{observed} and \code{estimated} otherwise
\item \code{se_min}, the lower bound of the standard error with a minimum of \code{0} (so the standard error will never go below 0\%)
\item \code{se_max} the upper bound of the standard error with a maximum of \code{1} (so the standard error will never go above 100\%)
\item \code{observations}, the total number of available observations in that year, i.e. \eqn{S + I + R}
\item \code{observed}, the original observed resistant percentages
\item \code{estimated}, the estimated resistant percentages, calculated by the model
2018-07-26 16:30:42 +02:00
}
Furthermore, the model itself is available as an attribute: \code{attributes(x)$model}, see \emph{Examples}.
2018-02-21 11:52:31 +01:00
}
\description{
Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns \code{se_min} and \code{se_max}. See \emph{Examples} for a real live example.
2018-02-21 11:52:31 +01:00
}
2019-02-09 22:16:24 +01:00
\details{
2020-12-22 00:51:17 +01:00
Valid options for the statistical model (argument \code{model}) are:
2019-02-09 22:16:24 +01:00
\itemize{
\item \code{"binomial"} or \code{"binom"} or \code{"logit"}: a generalised linear regression model with binomial distribution
\item \code{"loglin"} or \code{"poisson"}: a generalised log-linear regression model with poisson distribution
\item \code{"lin"} or \code{"linear"}: a linear regression model
2019-02-09 22:16:24 +01:00
}
}
2023-01-21 23:47:20 +01:00
\section{Interpretation of SIR}{
2019-11-11 10:46:39 +01:00
2023-07-10 13:41:52 +02:00
In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I, and R as shown below (\url{https://www.eucast.org/newsiandr}):
2019-11-11 10:46:39 +01:00
\itemize{
2023-01-21 23:47:20 +01:00
\item \strong{S - Susceptible, standard dosing regimen}\cr
A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
\item \strong{I - Susceptible, increased exposure} \emph{\cr
A microorganism is categorised as "Susceptible, Increased exposure}" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
2019-11-29 19:43:23 +01:00
\item \strong{R = Resistant}\cr
2023-01-21 23:47:20 +01:00
A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.
\itemize{
\item \emph{Exposure} is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
}
2019-11-11 10:46:39 +01:00
}
2022-11-13 13:44:25 +01:00
This AMR package honours this insight. Use \code{\link[=susceptibility]{susceptibility()}} (equal to \code{\link[=proportion_SI]{proportion_SI()}}) to determine antimicrobial susceptibility and \code{\link[=count_susceptible]{count_susceptible()}} (equal to \code{\link[=count_SI]{count_SI()}}) to count susceptible isolates.
2019-11-11 10:46:39 +01:00
}
2018-02-21 11:52:31 +01:00
\examples{
2022-08-28 10:31:50 +02:00
x <- resistance_predict(example_isolates,
col_ab = "AMX",
year_min = 2010,
model = "binomial"
)
2019-01-15 12:45:24 +01:00
plot(x)
2021-05-24 09:00:11 +02:00
\donttest{
2020-05-16 21:40:50 +02:00
if (require("ggplot2")) {
2023-01-21 23:47:20 +01:00
ggplot_sir_predict(x)
2020-05-16 21:40:50 +02:00
}
2018-04-02 16:05:09 +02:00
2020-05-16 13:05:47 +02:00
# using dplyr:
2020-05-16 21:40:50 +02:00
if (require("dplyr")) {
2020-05-16 13:05:47 +02:00
x <- example_isolates \%>\%
filter_first_isolate() \%>\%
filter(mo_genus(mo) == "Staphylococcus") \%>\%
resistance_predict("PEN", model = "binomial")
2022-08-27 20:49:37 +02:00
print(plot(x))
2020-05-16 13:05:47 +02:00
# get the model from the object
mymodel <- attributes(x)$model
summary(mymodel)
}
2019-02-11 10:27:10 +01:00
# create nice plots with ggplot2 yourself
2022-08-27 20:49:37 +02:00
if (require("dplyr") && require("ggplot2")) {
data <- example_isolates \%>\%
2018-12-22 22:39:34 +01:00
filter(mo == as.mo("E. coli")) \%>\%
2022-08-28 10:31:50 +02:00
resistance_predict(
col_ab = "AMX",
col_date = "date",
model = "binomial",
info = FALSE,
minimum = 15
)
2022-08-21 16:37:20 +02:00
head(data)
2021-07-12 20:24:49 +02:00
autoplot(data)
2018-07-26 16:30:42 +02:00
}
2018-02-21 11:52:31 +01:00
}
2021-05-24 09:00:11 +02:00
}
2018-02-21 11:52:31 +01:00
\seealso{
The \code{\link[=proportion]{proportion()}} functions to calculate resistance
Models: \code{\link[=lm]{lm()}} \code{\link[=glm]{glm()}}
2018-02-21 11:52:31 +01:00
}