From 916366a8d866c9040b6a987e24282c9575bc7c1e Mon Sep 17 00:00:00 2001 From: Amelie Lucker <amelie.lucker@itwm.fraunhofer.de> Date: Thu, 26 May 2022 16:52:47 +0200 Subject: [PATCH] changed negativ_person to negative_person --- R/calculate_likelihood_negative_tests.R | 14 +++++----- R/calculate_posterior_no_infections.R | 18 ++++++------- R/calculate_prior_infections.R | 22 ++++++++-------- doc/calculate_posterior_no_infections.R | 2 +- doc/calculate_posterior_no_infections.Rmd | 2 +- doc/calculate_prior_infections.R | 2 +- doc/calculate_prior_infections.Rmd | 2 +- doc/risk_assessment_group_quarantine.R | 6 ++--- doc/risk_assessment_group_quarantine.Rmd | 6 ++--- doc/risk_assessment_group_quarantine.html | 6 ++--- input/input_parameters.Rmd | 26 +++++++++---------- input/input_parameters.html | 26 +++++++++---------- man/calculate_likelihood_negative_tests.Rd | 6 ++--- man/calculate_posterior_no_infections.Rd | 6 ++--- man/calculate_prior_infections.Rd | 6 ++--- .../test_calculate_posterior_no_infections.R | 12 ++++----- .../risk_assessment_group_quarantine.Rmd | 18 ++++++------- 17 files changed, 90 insertions(+), 90 deletions(-) diff --git a/R/calculate_likelihood_negative_tests.R b/R/calculate_likelihood_negative_tests.R index 2b63006..3001722 100644 --- a/R/calculate_likelihood_negative_tests.R +++ b/R/calculate_likelihood_negative_tests.R @@ -9,7 +9,7 @@ #' @param test_infos Matrix with column number of test days and a column #' for each test with the testday relative to event date, the rows are the groups. #' @param test_types Matrix with test day (columns) of each group (rows) and whe informations about test types. -#' @param negativ_person Number of people without the infectious persons. +#' @param negative_person Number of people without the infectious persons. #' @param subgroup_size Array with the number of persons per test group. #' @param info Dataframe, this is a placeholder #' @return Vector of probabilities calculated. @@ -25,7 +25,7 @@ #' #' calculate_likelihood_negative_tests(test_infos = test_infos, #' test_types = test_types, -#' negativ_person = 23, +#' negative_person = 23, #' subgroup_size = c(3, 5)) #' #' @export @@ -33,21 +33,21 @@ calculate_likelihood_negative_tests <- function(test_infos, test_types, - negativ_person, + negative_person, subgroup_size, info) { val_calculate_lik(test_infos, test_types, - negativ_person, + negative_person, subgroup_size, info) if(missing(info)){ info <- get_test_sensitivities() } - information_data <- generate_data_extended(negativ_person, test_infos, subgroup_size) + information_data <- generate_data_extended(negative_person, test_infos, subgroup_size) number_subgroups <- max(information_data$group) # number of subgroups included untested (Gp in {G, G + 1}) number_group_peoples <- sapply(1:number_subgroups, function(g) sum(information_data$group == g)) # how many people per group? ## create Matrix GR with possible combinations how K infected are distributed among subgroups @@ -67,13 +67,13 @@ calculate_likelihood_negative_tests <- function(test_infos, val_calculate_lik <- function(test_infos, test_types, - negativ_person, + negative_person, subgroup_size, info){ smidm_is_double_matrix(test_infos) smidm_is_character_matrix(test_types) - smidm_is_natural_number(negativ_person) + smidm_is_natural_number(negative_person) smidm_is_positive_vector(subgroup_size) } diff --git a/R/calculate_posterior_no_infections.R b/R/calculate_posterior_no_infections.R index e52932c..74567f0 100644 --- a/R/calculate_posterior_no_infections.R +++ b/R/calculate_posterior_no_infections.R @@ -4,7 +4,7 @@ #' #' The probability is based on Bayes' theorem. #' -#' @param negativ_person Number of people without the infectious persons. +#' @param negative_person Number of people without the infectious persons. #' @param infected_person Number of infectious persons. #' @param event Characters, the name of the event, currently: "school" or "kita". #' @param test_infos Matrix with testing information; each row gives the number of @@ -27,7 +27,7 @@ #' test_types[1,] <- c("PCR", NA) #' test_types[2,] <- c("PCR", "Antigen") #' -#' calculate_posterior_no_infections(negativ_person = 23, +#' calculate_posterior_no_infections(negative_person = 23, #' infected_person = 2, #' event = "school", #' test_infos = test_infos, @@ -37,7 +37,7 @@ #' @export -calculate_posterior_no_infections <- function(negativ_person, +calculate_posterior_no_infections <- function(negative_person, infected_person, event, test_infos, @@ -46,7 +46,7 @@ calculate_posterior_no_infections <- function(negativ_person, distribution = NULL, info) { - val_calculate_probability_negative_analysis(negativ_person, + val_calculate_probability_negative_analysis(negative_person, infected_person, event, test_infos, @@ -58,7 +58,7 @@ calculate_posterior_no_infections <- function(negativ_person, if(event == "school"||event == "kita") { - aPriori <- calculate_prior_infections(negativ_person, infected_person, event) + aPriori <- calculate_prior_infections(negative_person, infected_person, event) } else { @@ -70,13 +70,13 @@ calculate_posterior_no_infections <- function(negativ_person, { negativeProbabilities <- calculate_likelihood_negative_tests(test_infos, test_types, - negativ_person, + negative_person, subgroup_size) }else { negativeProbabilities <- calculate_likelihood_negative_tests(test_infos, test_types, - negativ_person, + negative_person, subgroup_size, info) } @@ -84,7 +84,7 @@ calculate_posterior_no_infections <- function(negativ_person, return(p) } -val_calculate_probability_negative_analysis <- function(negativ_person, +val_calculate_probability_negative_analysis <- function(negative_person, infected_person, event, test_infos, @@ -93,7 +93,7 @@ val_calculate_probability_negative_analysis <- function(negativ_person, distribution, info){ - smidm_is_natural_number(negativ_person) + smidm_is_natural_number(negative_person) smidm_is_natural_number(infected_person) smidm_is_character(event) smidm_is_double_matrix(test_infos) diff --git a/R/calculate_prior_infections.R b/R/calculate_prior_infections.R index ab8710a..fc298f5 100644 --- a/R/calculate_prior_infections.R +++ b/R/calculate_prior_infections.R @@ -6,7 +6,7 @@ #' #' The probability is beta-binomial distributed, #' -#' @param negativ_person Number of people without the infectious persons. +#' @param negative_person Number of people without the infectious persons. #' @param infected_person Number of infected people. #' @param event Characters, event type given as characters, currently: "school" or "kita". #' @param p_one Number, this is a placeholder @@ -14,7 +14,7 @@ #' @return The a priori probability y. #' #' @examples -#' calculate_prior_infections(negativ_person = 23, +#' calculate_prior_infections(negative_person = 23, #' infected_person = 2, #' event = "school") #' @@ -22,13 +22,13 @@ #' @import extraDistr -calculate_prior_infections <- function(negativ_person, +calculate_prior_infections <- function(negative_person, infected_person, event, p_one = NULL, infect_average = NULL){ - val_get_apriori_probability(negativ_person, + val_get_apriori_probability(negative_person, infected_person, event, p_one, @@ -37,23 +37,23 @@ calculate_prior_infections <- function(negativ_person, if (event == "school") { p1 <- 0.14 infection_average <- 4.8 # = E[K|K>0] - pi <- scale01(infection_average, 1, (negativ_person + 1) / 2) + pi <- scale01(infection_average, 1, (negative_person + 1) / 2) } else if (event == "kita") { p1 <- 0.13 infection_average <- 5.1 # = E[K|K>0] - pi <- scale01(infection_average, 1, (negativ_person + 1) / 2) + pi <- scale01(infection_average, 1, (negative_person + 1) / 2) } else { p1 <- p_one infection_average <- infect_average - pi <- scale01(infection_average, 1, (negativ_person + 1) / 2) + pi <- scale01(infection_average, 1, (negative_person + 1) / 2) } - params <- findparsBeta(negativ_person, p1 = p1, pi = pi, w = c(1, 1)) - y <- extraDistr::dbbinom(0:negativ_person, negativ_person, alpha = params$a, beta = params$b) + params <- findparsBeta(negative_person, p1 = p1, pi = pi, w = c(1, 1)) + y <- extraDistr::dbbinom(0:negative_person, negative_person, alpha = params$a, beta = params$b) # Adapt for more than one primary case if (infected_person > 1) { @@ -67,13 +67,13 @@ calculate_prior_infections <- function(negativ_person, } -val_get_apriori_probability <- function(negativ_person, +val_get_apriori_probability <- function(negative_person, infected_person, event, p_one, infect_average){ - smidm_is_natural_number(negativ_person) + smidm_is_natural_number(negative_person) smidm_is_natural_number(infected_person) smidm_is_character(event) diff --git a/doc/calculate_posterior_no_infections.R b/doc/calculate_posterior_no_infections.R index 9732624..f21c346 100644 --- a/doc/calculate_posterior_no_infections.R +++ b/doc/calculate_posterior_no_infections.R @@ -17,7 +17,7 @@ test_types <- matrix(nrow = 1, ncol = 2) test_types[1, 1] <- "PCR" test_types[1, 2] <- "PCR" -negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, +negative_analysis <- calculate_posterior_no_infections(negative_person = 10, infected_person = 1, event = c("school"), test_infos = test_infos, diff --git a/doc/calculate_posterior_no_infections.Rmd b/doc/calculate_posterior_no_infections.Rmd index 55ffd87..ea4c4a2 100644 --- a/doc/calculate_posterior_no_infections.Rmd +++ b/doc/calculate_posterior_no_infections.Rmd @@ -38,7 +38,7 @@ test_types <- matrix(nrow = 1, ncol = 2) test_types[1, 1] <- "PCR" test_types[1, 2] <- "PCR" -negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, +negative_analysis <- calculate_posterior_no_infections(negative_person = 10, infected_person = 1, event = c("school"), test_infos = test_infos, diff --git a/doc/calculate_prior_infections.R b/doc/calculate_prior_infections.R index dd954fe..6fd9ce3 100644 --- a/doc/calculate_prior_infections.R +++ b/doc/calculate_prior_infections.R @@ -10,7 +10,7 @@ library(smidm) ## ----get_aPrioriProbability--------------------------------------------------- -likelihood <- get_aPrioriProbability(negativ_person = 15, +likelihood <- get_aPrioriProbability(negative_person = 15, infected_person = 1, event = "school") diff --git a/doc/calculate_prior_infections.Rmd b/doc/calculate_prior_infections.Rmd index e02c725..4d94243 100644 --- a/doc/calculate_prior_infections.Rmd +++ b/doc/calculate_prior_infections.Rmd @@ -33,7 +33,7 @@ Third, the name of the event (example "school"). ```{r get_aPrioriProbability} -likelihood <- get_aPrioriProbability(negativ_person = 15, +likelihood <- get_aPrioriProbability(negative_person = 15, infected_person = 1, event = "school") diff --git a/doc/risk_assessment_group_quarantine.R b/doc/risk_assessment_group_quarantine.R index 6b2662a..45022ac 100644 --- a/doc/risk_assessment_group_quarantine.R +++ b/doc/risk_assessment_group_quarantine.R @@ -23,7 +23,7 @@ test_types[1, 1] <- "PCR" test_types[2, 1] <- "PCR" test_types[2, 2] <- "Antigen" -prob <- calculate_posterior_no_infections(negativ_person = 23, +prob <- calculate_posterior_no_infections(negative_person = 23, infected_person = 2, event = "school", test_infos = test_infos, @@ -48,13 +48,13 @@ test_types[2, 2] <- "Antigen" likelihood <- calculate_likelihood_negative_tests(test_infos = test_infos, test_types = test_types, - negativ_person = 23, + negative_person = 23, subgroup_size = c(3, 5)) ## ----calculate_prior_infections----------------------------------------------- -likelihood <- calculate_prior_infections(negativ_person = 23, +likelihood <- calculate_prior_infections(negative_person = 23, infected_person = 2, event = "school") diff --git a/doc/risk_assessment_group_quarantine.Rmd b/doc/risk_assessment_group_quarantine.Rmd index 2576553..e959284 100644 --- a/doc/risk_assessment_group_quarantine.Rmd +++ b/doc/risk_assessment_group_quarantine.Rmd @@ -54,7 +54,7 @@ test_types[1, 1] <- "PCR" test_types[2, 1] <- "PCR" test_types[2, 2] <- "Antigen" -prob <- calculate_posterior_no_infections(negativ_person = 23, +prob <- calculate_posterior_no_infections(negative_person = 23, infected_person = 2, event = "school", test_infos = test_infos, @@ -92,7 +92,7 @@ test_types[2, 2] <- "Antigen" likelihood <- calculate_likelihood_negative_tests(test_infos = test_infos, test_types = test_types, - negativ_person = 23, + negative_person = 23, subgroup_size = c(3, 5)) ``` @@ -107,7 +107,7 @@ First, the number of people without the infectious persons, second, the number o ```{r calculate_prior_infections} -likelihood <- calculate_prior_infections(negativ_person = 23, +likelihood <- calculate_prior_infections(negative_person = 23, infected_person = 2, event = "school") ``` diff --git a/doc/risk_assessment_group_quarantine.html b/doc/risk_assessment_group_quarantine.html index 69260e7..5152f2e 100644 --- a/doc/risk_assessment_group_quarantine.html +++ b/doc/risk_assessment_group_quarantine.html @@ -362,7 +362,7 @@ code > span.er { color: #a61717; background-color: #e3d2d2; } <span id="cb1-11"><a href="#cb1-11"></a>test_types[<span class="dv">2</span>, <span class="dv">1</span>] <-<span class="st"> "PCR"</span></span> <span id="cb1-12"><a href="#cb1-12"></a>test_types[<span class="dv">2</span>, <span class="dv">2</span>] <-<span class="st"> "Antigen"</span></span> <span id="cb1-13"><a href="#cb1-13"></a></span> -<span id="cb1-14"><a href="#cb1-14"></a>prob <-<span class="st"> </span><span class="kw">calculate_posterior_no_infections</span>(<span class="dt">negativ_person =</span> <span class="dv">23</span>,</span> +<span id="cb1-14"><a href="#cb1-14"></a>prob <-<span class="st"> </span><span class="kw">calculate_posterior_no_infections</span>(<span class="dt">negative_person =</span> <span class="dv">23</span>,</span> <span id="cb1-15"><a href="#cb1-15"></a> <span class="dt">infected_person =</span> <span class="dv">2</span>,</span> <span id="cb1-16"><a href="#cb1-16"></a> <span class="dt">event =</span> <span class="st">"school"</span>,</span> <span id="cb1-17"><a href="#cb1-17"></a> <span class="dt">test_infos =</span> test_infos,</span> @@ -391,7 +391,7 @@ code > span.er { color: #a61717; background-color: #e3d2d2; } <span id="cb2-14"><a href="#cb2-14"></a></span> <span id="cb2-15"><a href="#cb2-15"></a>likelihood <-<span class="st"> </span><span class="kw">calculate_likelihood_negative_tests</span>(<span class="dt">test_infos =</span> test_infos,</span> <span id="cb2-16"><a href="#cb2-16"></a> <span class="dt">test_types =</span> test_types,</span> -<span id="cb2-17"><a href="#cb2-17"></a> <span class="dt">negativ_person =</span> <span class="dv">23</span>,</span> +<span id="cb2-17"><a href="#cb2-17"></a> <span class="dt">negative_person =</span> <span class="dv">23</span>,</span> <span id="cb2-18"><a href="#cb2-18"></a> <span class="dt">subgroup_size =</span> <span class="kw">c</span>(<span class="dv">3</span>, <span class="dv">5</span>))</span></code></pre></div> </div> <div id="a-priori-probability-of-further-infections-with-calculate_prior_infections" class="section level1"> @@ -399,7 +399,7 @@ code > span.er { color: #a61717; background-color: #e3d2d2; } <p>The function <code>calculate_prior_infections()</code> calculates the a priori probability of how many people are infected in one event.</p> <p>Multiple arguments are necessary for the function <code>calculate_prior_infections()</code> to work: First, the number of people without the infectious persons, second, the number of infectious persons and third, the name of the event (example “schoolâ€).</p> <div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a></span> -<span id="cb3-2"><a href="#cb3-2"></a>likelihood <-<span class="st"> </span><span class="kw">calculate_prior_infections</span>(<span class="dt">negativ_person =</span> <span class="dv">23</span>,</span> +<span id="cb3-2"><a href="#cb3-2"></a>likelihood <-<span class="st"> </span><span class="kw">calculate_prior_infections</span>(<span class="dt">negative_person =</span> <span class="dv">23</span>,</span> <span id="cb3-3"><a href="#cb3-3"></a> <span class="dt">infected_person =</span> <span class="dv">2</span>,</span> <span id="cb3-4"><a href="#cb3-4"></a> <span class="dt">event =</span> <span class="st">"school"</span>)</span></code></pre></div> </div> diff --git a/input/input_parameters.Rmd b/input/input_parameters.Rmd index 3040a9b..5829197 100644 --- a/input/input_parameters.Rmd +++ b/input/input_parameters.Rmd @@ -136,12 +136,12 @@ test_types[2, 2] <- "Antigen" likelihood <- calculate_likelihood_negative_tests(test_infos = test_infos, test_types = test_types, - negativ_person = 23, + negative_person = 23, subgroup_size = c(3, 5)) ``` -`calculate_likelihood_negative_tests.R` benötigt für den Aufruf mehrere Variabeln. Bei den ersten beiden Werten handelt es sich um zwei Matrizzen, bei der eine Matrix aus Charactern und die andere aus Double Zahlen besteht. Bei `negativ_person` handelt es sich um eine postive, natürliche Zahl. Die letzte Eingabe ist ein Vektor gefüllt mit postiven Zahlen. +`calculate_likelihood_negative_tests.R` benötigt für den Aufruf mehrere Variabeln. Bei den ersten beiden Werten handelt es sich um zwei Matrizzen, bei der eine Matrix aus Charactern und die andere aus Double Zahlen besteht. Bei `negative_person` handelt es sich um eine postive, natürliche Zahl. Die letzte Eingabe ist ein Vektor gefüllt mit postiven Zahlen. Eine Validationsfunktion könnte wie folgt aussehen: @@ -149,7 +149,7 @@ Eine Validationsfunktion könnte wie folgt aussehen: validate_calculate_likelihood_negative_tests <- function(test_infos, test_types, - negativ_person, + negative_person, subgroup_size) { if (typeof(test_types) != "double") { @@ -158,8 +158,8 @@ validate_calculate_likelihood_negative_tests <- function(test_infos, if (typeof(test_types) != "character") { stop("`test_types` must be a character matrix", call. = FALSE) } - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!(length(subgroup_size[subgroup_size >= 0]) == length(subgroup_size)) ) { stop("`subgroup_size` must be a positiv vector with numbers", call. = FALSE) @@ -183,7 +183,7 @@ distribution <- c(0.19952580, 0.11559084, 0.09281880, 0.08164757, 0.07513202, 0. 0.06893753, 0.06820342, 0.06916264, 0.07290075, 0.08491634) -negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, +negative_analysis <- calculate_posterior_no_infections(negative_person = 10, infected_person = 5, event = "uni", test_infos, @@ -200,7 +200,7 @@ Eine Validationsfunktion könnte wie folgt aussehen: ```{r validation_calculate_posterior_no_infections} -validation_calculate_posterior_no_infections <- function(negativ_person, +validation_calculate_posterior_no_infections <- function(negative_person, infected_person, event, test_infos, @@ -209,8 +209,8 @@ validation_calculate_posterior_no_infections <- function(negativ_person, distribution) { - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!is_natural_number(infected_person)) { stop("`infected_person` must be a positive natural number", call. = FALSE) @@ -375,7 +375,7 @@ validation_get_test_sensitivities <- function(df) { ```{r calculate_prior_infections} -apriori <- calculate_prior_infections(negativ_person = 20, +apriori <- calculate_prior_infections(negative_person = 20, infected_person = 5, event = "uni", p_one = 0.14, @@ -390,13 +390,13 @@ Eine Validationsfunktion könnte wie folgt aussehen: ```{r validation_calculate_prior_infections} -validation_calculate_prior_infections <- function(negativ_person, +validation_calculate_prior_infections <- function(negative_person, infected_person, event, p_one, infect_average) { - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!is_natural_number(infected_person)) { stop("`infected_person` must be a positive natural number", call. = FALSE) diff --git a/input/input_parameters.html b/input/input_parameters.html index 79cacb2..2356bb9 100644 --- a/input/input_parameters.html +++ b/input/input_parameters.html @@ -355,13 +355,13 @@ test_types[2, 2] <- "Antigen" likelihood <- calculate_likelihood_negative_tests(test_infos = test_infos, test_types = test_types, - negativ_person = 23, + negative_person = 23, subgroup_size = c(3, 5))</code></pre> -<p><code>calculate_likelihood_negative_tests.R</code> benötigt für den Aufruf mehrere Variabeln. Bei den ersten beiden Werten handelt es sich um zwei Matrizzen, bei der eine Matrix aus Charactern und die andere aus Double Zahlen besteht. Bei <code>negativ_person</code> handelt es sich um eine postive, natürliche Zahl. Die letzte Eingabe ist ein Vektor gefüllt mit postiven Zahlen.</p> +<p><code>calculate_likelihood_negative_tests.R</code> benötigt für den Aufruf mehrere Variabeln. Bei den ersten beiden Werten handelt es sich um zwei Matrizzen, bei der eine Matrix aus Charactern und die andere aus Double Zahlen besteht. Bei <code>negative_person</code> handelt es sich um eine postive, natürliche Zahl. Die letzte Eingabe ist ein Vektor gefüllt mit postiven Zahlen.</p> <p>Eine Validationsfunktion könnte wie folgt aussehen:</p> <pre class="r"><code>validate_calculate_likelihood_negative_tests <- function(test_infos, test_types, - negativ_person, + negative_person, subgroup_size) { if (typeof(test_types) != "double") { @@ -370,8 +370,8 @@ likelihood <- calculate_likelihood_negative_tests(test_infos = test_infos, if (typeof(test_types) != "character") { stop("`test_types` must be a character matrix", call. = FALSE) } - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!(length(subgroup_size[subgroup_size >= 0]) == length(subgroup_size)) ) { stop("`subgroup_size` must be a positiv vector with numbers", call. = FALSE) @@ -391,7 +391,7 @@ distribution <- c(0.19952580, 0.11559084, 0.09281880, 0.08164757, 0.07513202, 0.06893753, 0.06820342, 0.06916264, 0.07290075, 0.08491634) -negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, +negative_analysis <- calculate_posterior_no_infections(negative_person = 10, infected_person = 5, event = "uni", test_infos, @@ -400,7 +400,7 @@ negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, distribution)</code></pre> <p><code>calculate_posterior_no_infections.R</code> benötigt für den Aufruf mehrere Variabeln. Bei den ersten beiden Werten handelt es sich um zwei einfache positive natürliche Zahlen, die per Standard Abfrage geprüft werden können. Bei der Variabel <code>event</code>handelt es sich um einen einfachen String. <code>test_infos</code>und <code>test_types</code>sind zwei Matrizen, die komplizierter zu überprüfen sind. Bei den letzten beiden Variabeln handelt es sich um einfache Vektoren.</p> <p>Eine Validationsfunktion könnte wie folgt aussehen:</p> -<pre class="r"><code>validation_calculate_posterior_no_infections <- function(negativ_person, +<pre class="r"><code>validation_calculate_posterior_no_infections <- function(negative_person, infected_person, event, test_infos, @@ -409,8 +409,8 @@ negative_analysis <- calculate_posterior_no_infections(negativ_person = 10, distribution) { - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!is_natural_number(infected_person)) { stop("`infected_person` must be a positive natural number", call. = FALSE) @@ -538,20 +538,20 @@ info <- get_test_sensitivities(df)</code></pre> </div> <div id="calculate_prior_infections.r" class="section level3"> <h3><code>calculate_prior_infections.R</code></h3> -<pre class="r"><code>apriori <- calculate_prior_infections(negativ_person = 20, +<pre class="r"><code>apriori <- calculate_prior_infections(negative_person = 20, infected_person = 5, event = "uni", p_one = 0.14, infect_average = 4.8)</code></pre> <p><code>calculate_prior_infections.R</code> benötigt für den Aufruf verschiedene Eingaben. Allerdings handelt es sich hierbei wieder nur um positive Zahlen und einem String.</p> <p>Eine Validationsfunktion könnte wie folgt aussehen:</p> -<pre class="r"><code>validation_calculate_prior_infections <- function(negativ_person, +<pre class="r"><code>validation_calculate_prior_infections <- function(negative_person, infected_person, event, p_one, infect_average) { - if (!is_natural_number(negativ_person)) { - stop("`negativ_person` must be a positive natural number", call. = FALSE) + if (!is_natural_number(negative_person)) { + stop("`negative_person` must be a positive natural number", call. = FALSE) } if (!is_natural_number(infected_person)) { stop("`infected_person` must be a positive natural number", call. = FALSE) diff --git a/man/calculate_likelihood_negative_tests.Rd b/man/calculate_likelihood_negative_tests.Rd index 4bd410f..3461a78 100644 --- a/man/calculate_likelihood_negative_tests.Rd +++ b/man/calculate_likelihood_negative_tests.Rd @@ -7,7 +7,7 @@ calculate_likelihood_negative_tests( test_infos, test_types, - negativ_person, + negative_person, subgroup_size, info ) @@ -18,7 +18,7 @@ for each test with the testday relative to event date, the rows are the groups.} \item{test_types}{Matrix with test day (columns) of each group (rows) and whe informations about test types.} -\item{negativ_person}{Number of people without the infectious persons.} +\item{negative_person}{Number of people without the infectious persons.} \item{subgroup_size}{Array with the number of persons per test group.} @@ -42,7 +42,7 @@ test_types[2,] <- c("PCR", "Antigen") calculate_likelihood_negative_tests(test_infos = test_infos, test_types = test_types, - negativ_person = 23, + negative_person = 23, subgroup_size = c(3, 5)) } diff --git a/man/calculate_posterior_no_infections.Rd b/man/calculate_posterior_no_infections.Rd index 9a06667..8c39720 100644 --- a/man/calculate_posterior_no_infections.Rd +++ b/man/calculate_posterior_no_infections.Rd @@ -5,7 +5,7 @@ \title{Negative analysis probability} \usage{ calculate_posterior_no_infections( - negativ_person, + negative_person, infected_person, event, test_infos, @@ -16,7 +16,7 @@ calculate_posterior_no_infections( ) } \arguments{ -\item{negativ_person}{Number of people without the infectious persons.} +\item{negative_person}{Number of people without the infectious persons.} \item{infected_person}{Number of infectious persons.} @@ -51,7 +51,7 @@ test_types <- matrix(nrow = 2, ncol = 2) test_types[1,] <- c("PCR", NA) test_types[2,] <- c("PCR", "Antigen") -calculate_posterior_no_infections(negativ_person = 23, +calculate_posterior_no_infections(negative_person = 23, infected_person = 2, event = "school", test_infos = test_infos, diff --git a/man/calculate_prior_infections.Rd b/man/calculate_prior_infections.Rd index 2919ec2..ce7b7b8 100644 --- a/man/calculate_prior_infections.Rd +++ b/man/calculate_prior_infections.Rd @@ -5,7 +5,7 @@ \title{A priori probability of further Infections} \usage{ calculate_prior_infections( - negativ_person, + negative_person, infected_person, event, p_one = NULL, @@ -13,7 +13,7 @@ calculate_prior_infections( ) } \arguments{ -\item{negativ_person}{Number of people without the infectious persons.} +\item{negative_person}{Number of people without the infectious persons.} \item{infected_person}{Number of infected people.} @@ -33,7 +33,7 @@ Calculates the a priori probability of how many people are infected in one event The probability is beta-binomial distributed, } \examples{ -calculate_prior_infections(negativ_person = 23, +calculate_prior_infections(negative_person = 23, infected_person = 2, event = "school") diff --git a/tests/testthat/test_calculate_posterior_no_infections.R b/tests/testthat/test_calculate_posterior_no_infections.R index fae54b8..f9dbab6 100644 --- a/tests/testthat/test_calculate_posterior_no_infections.R +++ b/tests/testthat/test_calculate_posterior_no_infections.R @@ -81,7 +81,7 @@ test_that("calculate_posterior_no_infections_kita_1", { test_that("calculate_posterior_no_infections_other_event_1", { - negativ_person = 23 + negative_person = 23 infected_person = 2 event = "work" subgroup_size = c(3, 5) @@ -104,7 +104,7 @@ test_that("calculate_posterior_no_infections_other_event_1", { 0.008148212, 0.007711506, 0.007323692, 0.006977206, 0.006666148, 0.006385981, 0.006133470, 0.005907169, 0.005710605) - expect_equal(round(calculate_posterior_no_infections(negativ_person, + expect_equal(round(calculate_posterior_no_infections(negative_person, infected_person, event, test_infos, @@ -115,7 +115,7 @@ test_that("calculate_posterior_no_infections_other_event_1", { test_that("calculate_posterior_no_infections_other_event_2", { - negativ_person = 10 + negative_person = 10 infected_person = 5 event = "uni" subgroup_size = c(1) @@ -131,7 +131,7 @@ test_that("calculate_posterior_no_infections_other_event_2", { distribution <- c(0.19952580, 0.11559084, 0.09281880, 0.08164757, 0.07513202, 0.07116430, 0.06893753, 0.06820342, 0.06916264, 0.07290075, 0.08491634) - expect_equal(round(calculate_posterior_no_infections(negativ_person, + expect_equal(round(calculate_posterior_no_infections(negative_person, infected_person, event, test_infos, @@ -143,7 +143,7 @@ test_that("calculate_posterior_no_infections_other_event_2", { test_that("calculate_posterior_no_infections_other_informations", { - negativ_person = 10 + negative_person = 10 infected_person = 5 event = "school" subgroup_size = c(1) @@ -162,7 +162,7 @@ test_that("calculate_posterior_no_infections_other_informations", { 0.29, 0.33, 0.375, 0.42, 0.465, 0.51, 0.56, 0.60, 0.63, 0.67)) info <- get_test_sensitivities() - expect_equal(round(calculate_posterior_no_infections(negativ_person, + expect_equal(round(calculate_posterior_no_infections(negative_person, infected_person, event, test_infos, diff --git a/vignettes/risk_assessment_group_quarantine.Rmd b/vignettes/risk_assessment_group_quarantine.Rmd index 2182235..ecff965 100644 --- a/vignettes/risk_assessment_group_quarantine.Rmd +++ b/vignettes/risk_assessment_group_quarantine.Rmd @@ -67,11 +67,11 @@ How likely is it that the two cases did not transmit COVID-19 and that no furthe The function `calculate_posterior_no_infections()` calculates the probability that nobody is infected given the negative tests. To that end, the following input values are required: -The input `negativ_person` denotes the number of people without the infectious persons and `infected_person` denotes the number of primary COVID-19 cases in the school class. Furthermore, the event type `event` describes the setting of the meeting. In the package the event types `school` (school class) and `kita` (daycare center) were modeled. +The input `negative_person` denotes the number of people without the infectious persons and `infected_person` denotes the number of primary COVID-19 cases in the school class. Furthermore, the event type `event` describes the setting of the meeting. In the package the event types `school` (school class) and `kita` (daycare center) were modeled. In addition, the information about the conducted tests `test_infos`, the conducted test types `test_types` and the number of persons which were tested at each days `subgroup_size` are needed. Each row of `test_infos`, `test_types` and each entry of `subgroup_size` describes one group of persons, which were tested in the same way on the same dates. `test_infos` describes in the first column how many tests and the following columns on which days after the event they were conducted, and `test_types` contains in each column which kind of test was conducted at the corresponding date. -Beside this, `distribution` as well as `info` are optional inputs, which can be set to use an own, custom prior distribution and own custom tests. `distribution` should be a probability vector, containing the probabilities that one COVID-19 case infects 0, ..., `negativ_person` persons. For `info` a data frame with one column containing the day-specific sensitivities of the considered test after infection has to be created and the column should have the name of the considered tests. The specificity of the test is not affecting the likelihood, since no positive tests results are assumed. +Beside this, `distribution` as well as `info` are optional inputs, which can be set to use an own, custom prior distribution and own custom tests. `distribution` should be a probability vector, containing the probabilities that one COVID-19 case infects 0, ..., `negative_person` persons. For `info` a data frame with one column containing the day-specific sensitivities of the considered test after infection has to be created and the column should have the name of the considered tests. The specificity of the test is not affecting the likelihood, since no positive tests results are assumed. ### Methodology @@ -81,7 +81,7 @@ The function `calculate_posterior_no_infections()` uses `calculate_likelihood_ne ```{r calculate_posterior_no_infections_statement} -negativ_person = 23 +negative_person = 23 infected_person = 2 event = "school" @@ -100,7 +100,7 @@ test_types[2, 2] <- "Antigen" subgroup_size = c(3, 5) -prob <- calculate_posterior_no_infections(negativ_person, +prob <- calculate_posterior_no_infections(negative_person, infected_person, event, test_infos, @@ -119,7 +119,7 @@ The function `calculate_likelihood_negative_tests()` is used to calculate the ve ### Inputs -The `calculate_likelihood_negative_tests()` uses some inputs of `calculate_posterior_no_infections`, namely `negativ_person`, `test_infos`, `test_types` and `subgroup_size`. +The `calculate_likelihood_negative_tests()` uses some inputs of `calculate_posterior_no_infections`, namely `negative_person`, `test_infos`, `test_types` and `subgroup_size`. Beside this, also `info` is an optional input, which can be set for using own custom tests. @@ -142,12 +142,12 @@ test_types[1, 1] <- "PCR" test_types[2, 1] <- "PCR" test_types[2, 2] <- "Antigen" -negativ_person = 23 +negative_person = 23 subgroup_size = c(3, 5) likelihood <- calculate_likelihood_negative_tests(test_infos, test_types, - negativ_person, + negative_person, subgroup_size) print(likelihood) @@ -173,11 +173,11 @@ The priori probability distribution as part of the bayesian statistical model is ### Outputs ```{r calculate_prior_infections} -negativ_person = 23 +negative_person = 23 infected_person = 2 event = "school" -prior <- calculate_prior_infections(negativ_person, +prior <- calculate_prior_infections(negative_person, infected_person, event) print(prior) -- GitLab