Skip to content

Commit

Permalink
Process contact matrix in main fn, WIP #68
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Feb 28, 2023
1 parent a9161ec commit 11dea23
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/final_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ final_size <- function(r0,
Y = r0 * contact_matrix
)

# set contact_matrix values to zero if there are no contacts among ...
# demography groups, or if demography groups are empty
i_here <- demography_vector_spread == 0 | as.vector(susceptibility) == 0 |
rowSums(contact_matrix_spread) == 0
contact_matrix_spread[i_here, i_here] <- 0.0

# process contact matrix in solver specific ways
contact_matrix_spread <- switch(solver,
iterative = t(t(contact_matrix_spread) * demography_vector_spread),
newton = t(t(contact_matrix_spread * as.vector(susceptibility)) *
demography_vector_spread)
)

# get group wise final sizes
epi_final_size <- .final_size(
c(
Expand Down

0 comments on commit 11dea23

Please sign in to comment.