Skip to content

Commit

Permalink
changed output of calc_network_R from R_var to R_net
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jan 25, 2024
1 parent 7a04563 commit 9b2e9df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions R/calc_network_R.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' age limits of individuals in the network.
#'
#' @return A named `numeric` vector of length 2, the unadjusted (`R`)
#' and corrected (`R_var`) estimates of \eqn{R}.
#' and network adjusted (`R_net`) estimates of \eqn{R}.
#' @export
#'
#' @examples
Expand Down Expand Up @@ -51,10 +51,10 @@ calc_network_R <- function(mean_num_contact,

# calculate R0 with and without correction
R <- beta * contacts_per_time[["mean"]] * infect_duration
R_var <- beta * infect_duration *
R_net <- beta * infect_duration *
(contacts_per_time[["mean"]] + contacts_per_time[["var"]] /
contacts_per_time[["mean"]])

# return R0 with and without variance correction
c(R = R, R_var = R_var)
c(R = R, R_net = R_net)
}
2 changes: 1 addition & 1 deletion man/calc_network_R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-calc_network_R.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("calc_network_R works as expected", {
prob_transmission = 1,
age_range = c(15, 75)
)
expect_equal(R, c(R = 0.25, R_var = 3.0277778))
expect_equal(R, c(R = 0.25, R_net = 3.0277778))
})

test_that("calc_network_R gives equal values when sd is zero", {
Expand All @@ -17,6 +17,6 @@ test_that("calc_network_R gives equal values when sd is zero", {
prob_transmission = 1,
age_range = c(15, 75)
)
expect_equal(R, c(R = 0.25, R_var = 0.25))
expect_equal(R, c(R = 0.25, R_net = 0.25))
})

10 changes: 5 additions & 5 deletions vignettes/heterogeneous_network_outbreaks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ R <- t(apply(
res <- cbind(params, R)
res <- reshape(
data = res,
varying = c("R", "R_var"),
varying = c("R", "R_net"),
v.names = "R",
direction = "long",
times = c("R", "R_var"),
times = c("R", "R_net"),
timevar = "group"
)
```
Expand Down Expand Up @@ -107,7 +107,7 @@ ggplot(data = res) +
) +
facet_wrap(
vars(group),
labeller = as_labeller(c(R = "R", R_var = "Adjusted R"))
labeller = as_labeller(c(R = "R", R_net = "Adjusted R"))
) +
scale_fill_viridis_c(
trans = "log",
Expand Down Expand Up @@ -136,10 +136,10 @@ res <- do.call(rbind, res)
res <- as.data.frame(cbind(beta, res))
res <- reshape(
data = res,
varying = c("R", "R_var"),
varying = c("R", "R_net"),
v.names = "R",
direction = "long",
times = c("R", "R_var"),
times = c("R", "R_net"),
timevar = "group"
)
```
Expand Down

0 comments on commit 9b2e9df

Please sign in to comment.