mac-theobio / McMasterPandemic

SEIR+ model
GNU General Public License v3.0
20 stars 5 forks source link

Concern about R0 calculation for vaxified models #232

Open stevencarlislewalker opened 2 years ago

stevencarlislewalker commented 2 years ago

Context

I'm building R0 functionality in the TMB engine and have been doing sanity checks by comparing the results using the TMB engine with those using the R engine. In making these comparisons I've found some issues that I will report here, but I have not yet spent the required time to do a proper bug report.

Details

The get_R0 function allows for two methods: analytical and kernel. The default is analytical and there is a comment in get_R0 that this analytical method will need to be reconsidered for structured models. This suggests to me that R0 for structured models (e.g. vaxified models) may not be correct. If they are indeed incorrect then there should be an error or at least a warning, which there is not. On the other hand, selecting the kernel method (which I believe to be more general and therefore potentially valid for vaxified models) generates this error for vaxified models.

> get_R0(params, method = "kernel")
Error in make_beta(state, params) : 
  if params are vaxified, state also needs to be vaxified

The error results because of this line in transKernel.

state <- make_state(N = 1, E0 = 1, use_eigvec = FALSE)

This state vector is passed to the simulation for producing the kernel. However, this state variable assumes the base unstructured model so if you pass a vaxified parameter vector you get a mismatch.

If I try to fix this issue by making state with explicit vaxification, I get this.

> make_state(N = 1, E0 = 1, use_eigvec = FALSE, vaxify = TRUE)
Error in `build_longer_spec()`:
! `cols` must select at least one column.
Run `rlang::last_error()` to see where the error occurred.