mirror of
https://github.com/msberends/AMR.git
synced 2025-07-10 13:01:58 +02:00
get episode unit tests
This commit is contained in:
@ -12,9 +12,9 @@ is_new_episode(x, episode_days = NULL, case_free_days = NULL, ...)
|
||||
\arguments{
|
||||
\item{x}{vector of dates (class \code{Date} or \code{POSIXt}), will be sorted internally to determine episodes}
|
||||
|
||||
\item{episode_days}{episode length in days, can also be less than a day or \code{Inf}, see \emph{Details}}
|
||||
\item{episode_days}{episode length in days to specify the time period after which a new episode begins, can also be less than a day or \code{Inf}, see \emph{Details}}
|
||||
|
||||
\item{case_free_days}{length in days after which new episode will start, can also be less than a day or \code{Inf}, see \emph{Details}}
|
||||
\item{case_free_days}{(inter-epidemic) interval length in days after which a new episode will start, can also be less than a day or \code{Inf}, see \emph{Details}}
|
||||
|
||||
\item{...}{ignored, only in place to allow future extensions}
|
||||
}
|
||||
@ -25,7 +25,7 @@ is_new_episode(x, episode_days = NULL, case_free_days = NULL, ...)
|
||||
}
|
||||
}
|
||||
\description{
|
||||
These functions determine which items in a vector can be considered (the start of) a new episode, based on the argument \code{episode_days}. This can be used to determine clinical episodes for any epidemiological analysis. The \code{\link[=get_episode]{get_episode()}} function returns the index number of the episode per group, while the \code{\link[=is_new_episode]{is_new_episode()}} function returns \code{TRUE} for every new \code{\link[=get_episode]{get_episode()}} index. Both absolute and relative episode determination are supported.
|
||||
These functions determine which items in a vector can be considered (the start of) a new episode. This can be used to determine clinical episodes for any epidemiological analysis. The \code{\link[=get_episode]{get_episode()}} function returns the index number of the episode per group, while the \code{\link[=is_new_episode]{is_new_episode()}} function returns \code{TRUE} for every new \code{\link[=get_episode]{get_episode()}} index. Both absolute and relative episode determination are supported.
|
||||
}
|
||||
\details{
|
||||
Episodes can be determined in two ways: absolute and relative.
|
||||
@ -37,7 +37,7 @@ This method uses \code{episode_days} to define an episode length in days, after
|
||||
Thus, this method counts \strong{since the start of the previous episode}.
|
||||
\item Relative
|
||||
|
||||
This method uses \code{case_free_days} to quantify the duration of (inter-epidemic) intervals, after which a new episode will start. A common use case is infectious disease epidemiology: episodes of norovirus outbreaks in a hospital for example. The case-free period could then be 14 days, so that new norovirus cases after that time will be considered a different (or new) episode.
|
||||
This method uses \code{case_free_days} to quantify the duration of case-free days (the inter-epidemic interval), after which a new episode will start. A common use case is infectious disease epidemiology: episodes of norovirus outbreaks in a hospital for example. The case-free period could then be 14 days, so that new norovirus cases after that time will be considered a different (or new) episode.
|
||||
|
||||
Thus, this methods counts \strong{since the last case in the previous episode}.
|
||||
}
|
||||
@ -47,8 +47,8 @@ In a table:\tabular{ccc}{
|
||||
2023-01-01 \tab 1 \tab 1 \cr
|
||||
2023-01-02 \tab 1 \tab 1 \cr
|
||||
2023-01-05 \tab 1 \tab 1 \cr
|
||||
2023-01-08 \tab 2\code{*} \tab 1 \cr
|
||||
2023-02-21 \tab 3 \tab 2\code{**} \cr
|
||||
2023-01-08 \tab 2** \tab 1 \cr
|
||||
2023-02-21 \tab 3 \tab 2*** \cr
|
||||
2023-02-22 \tab 3 \tab 2 \cr
|
||||
2023-02-23 \tab 3 \tab 2 \cr
|
||||
2023-02-24 \tab 3 \tab 2 \cr
|
||||
@ -56,8 +56,10 @@ In a table:\tabular{ccc}{
|
||||
}
|
||||
|
||||
|
||||
\code{*} This marks the start of a new episode, because 8 January 2023 is more than 7 days since the start of the previous episode (1 January 2023). \cr
|
||||
\code{**} This marks the start of a new episode, because 21 January 2023 is more than 7 days since the last case in the previous episode (8 January 2023).
|
||||
** This marks the start of a new episode, because 8 January 2023 is more than 7 days since the start of the previous episode (1 January 2023). \cr
|
||||
*** This marks the start of a new episode, because 21 January 2023 is more than 7 days since the last case in the previous episode (8 January 2023).
|
||||
|
||||
Either \code{episode_days} or \code{case_free_days} must be provided in the function.
|
||||
\subsection{Difference between \code{get_episode()} and \code{is_new_episode()}}{
|
||||
|
||||
The \code{\link[=get_episode]{get_episode()}} function returns the index number of the episode, so all cases/patients/isolates in the first episode will have the number 1, all cases/patients/isolates in the second episode will have the number 2, etc.
|
||||
|
Reference in New Issue
Block a user