Commit 35f04b91 authored by Chris Jewell's avatar Chris Jewell
Browse files

Change to Rt calculation to fix discretisation error

Investigation showed that the high rate of cases in the UK in January
caused a significant discretisation error between the chain binomial
model and continuous time analogues.  The previous Rt calculation
made use of a continuous time approximation, and so gave biased
estimates of Rt.

The new implementation calculates Rt using expectations of the chain
binomial model in terms of transition probabilities, not rates as
previously.
parent 62f9ec37
......@@ -250,15 +250,17 @@ def next_generation_matrix_fn(covar_data, param):
beta = tf.math.exp(xi)
ngm = beta * (
tf.eye(Cstar.shape[0], dtype=state.dtype)
+ param["beta2"] * commute_volume * Cstar / N[tf.newaxis, :]
)
ngm = (
ngm
* state[..., 0][..., tf.newaxis]
/ (N[:, tf.newaxis] * tf.math.exp(param["gamma0"]))
beta
* (
tf.eye(Cstar.shape[0], dtype=state.dtype)
+ param["beta2"] * commute_volume * Cstar / N[tf.newaxis, :]
)
/ N[:, tf.newaxis]
)
ngm = (1.0 - tf.math.exp(-ngm)) * state[..., 0][..., tf.newaxis]
ngm = ngm / (1 - tf.math.exp(-tf.math.exp(param["gamma0"])))
return ngm
return fn
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment