epiverse-trace / finalsize

R package to calculate the final size of an SIR epidemic in populations with heterogeneity in social contacts and disease susceptibility
https://epiverse-trace.github.io/finalsize/
Other
11 stars 7 forks source link

p_susceptibility implementation for final_size R #12

Closed pratikunterwegs closed 2 years ago

pratikunterwegs commented 2 years ago

Adding functionality to handle populations with non uniform distribution of susceptibilities in current finalsize function final_size in R.

This will add a p_susceptibility (or similar) argument to final_size.

End point is a function whose functionality is in line with the proposed final_size_cpp function whose underlying Cpp code already implements heterogenous susceptibility distributions across age groups.

BlackEdder commented 2 years ago

I have addressed some of the problems with the contact matrix in #26 , but we need further changes in the code.

The cpp function will need to accept an r0 here: https://github.com/epiverse-trace/finalsize/blob/f59f61af8527d5225686fe934c6ff431be585a0f/R/final_size_cpp.R#L14

Then https://github.com/epiverse-trace/finalsize/blob/f59f61af8527d5225686fe934c6ff431be585a0f/R/final_size_cpp.R#L27 needs to change to

contact_matrix <- r0*contact_matrix / (max(Re(eigen(contact_matrix)$values)))

The current issue is that by rescaling the contact matrix you basically set r0 to 1, which results in a final size close to 0

pratikunterwegs commented 2 years ago

This issue is fixed by #42