1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 07:26:11 +01:00
AMR/man/rsi_predict.Rd

79 lines
2.9 KiB
Plaintext
Raw Normal View History

2018-02-21 11:52:31 +01:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rsi_analysis.R
\name{rsi_predict}
\alias{rsi_predict}
\title{Predict antimicrobial resistance}
\usage{
2018-02-26 12:15:52 +01:00
rsi_predict(tbl, col_ab, col_date,
2018-02-21 11:52:31 +01:00
year_max = as.integer(format(as.Date(Sys.Date()), "\%Y")) + 15,
year_every = 1, model = "binomial", I_as_R = TRUE,
preserve_measurements = TRUE, info = TRUE)
}
\arguments{
\item{tbl}{table that contains columns \code{col_ab} and \code{col_date}}
2018-02-27 20:01:02 +01:00
\item{col_ab}{column name of \code{tbl} with antimicrobial interpretations (\code{R}, \code{I} and \code{S}), supports tidyverse-like quotation}
2018-02-21 11:52:31 +01:00
2018-02-27 20:01:02 +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, supports tidyverse-like quotation}
2018-02-21 11:52:31 +01:00
\item{year_max}{highest year to use in the prediction model, deafults to 15 years after today}
\item{year_every}{unit of sequence between lowest year found in the data and \code{year_max}}
\item{model}{the statistical model of choice. Valid values are \code{"binomial"} (or \code{"binom"} or \code{"logit"}) or \code{"loglin"} or \code{"linear"} (or \code{"lin"}).}
\item{I_as_R}{treat \code{I} as \code{R}}
\item{preserve_measurements}{overwrite predictions of years that are actually available in the data, with the original data. The standard errors of those years will be \code{NA}.}
\item{info}{print textual analysis with the name and \code{\link{summary}} of the model.}
}
\value{
\code{data.frame} with columns \code{year}, \code{probR}, \code{se_min} and \code{se_max}.
}
\description{
2018-02-27 20:01:02 +01:00
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 Examples for a real live example.
2018-02-21 11:52:31 +01:00
}
\examples{
\dontrun{
# use it directly:
2018-02-26 15:53:09 +01:00
rsi_predict(tbl = tbl[which(first_isolate == TRUE & genus == "Haemophilus"),],
2018-02-27 20:01:02 +01:00
col_ab = "amcl", col_date = "date")
2018-02-21 11:52:31 +01:00
# or with dplyr so you can actually read it:
2018-02-22 20:48:48 +01:00
library(dplyr)
2018-02-21 11:52:31 +01:00
tbl \%>\%
filter(first_isolate == TRUE,
genus == "Haemophilus") \%>\%
2018-02-27 20:01:02 +01:00
rsi_predict(amcl, date)
}
2018-02-21 11:52:31 +01:00
2018-02-27 20:01:02 +01:00
# real live example:
library(dplyr)
septic_patients \%>\%
# get bacteria properties like genus and species
left_join_microorganisms("bactid") \%>\%
2018-02-27 20:01:02 +01:00
# calculate first isolates
mutate(first_isolate =
first_isolate(.,
"date",
"patient_id",
2018-03-27 17:43:42 +02:00
"bactid",
2018-02-27 20:01:02 +01:00
col_specimen = NA,
col_icu = NA)) \%>\%
# filter on first E. coli isolates
filter(genus == "Escherichia",
species == "coli",
first_isolate == TRUE) \%>\%
# predict resistance of cefotaxime for next years
rsi_predict(col_ab = cfot,
col_date = date,
year_max = 2025,
preserve_measurements = FALSE)
2018-02-21 11:52:31 +01:00
}
\seealso{
\code{\link{lm}} \cr \code{\link{glm}}
}