-
-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SIR model with unknown time of initial infection #2460
Conversation
@fehiepsi would you mind reviewing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks reasonable.
didn't review index magic.
pyro/contrib/epidemiology/sir.py
Outdated
self.pre_window = pre_window | ||
self.post_window = len(data) | ||
|
||
# Expect a single external infection during the pre_window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please explain this assumption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# after observations were made (in post_window). | ||
rho0 = pyro.sample("rho0", dist.Uniform(0, 1)) | ||
rho1 = pyro.sample("rho1", dist.Uniform(0, 1)) | ||
rho = torch.cat([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on shape of rho?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
S2I = pyro.sample("S2I_{}".format(t), | ||
infection_dist(individual_rate=R0 / tau, | ||
num_susceptible=state["S"], | ||
num_infectious=state["I"] + X, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess the X
contribution is active at all times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. That modeling decision seems more parsimonious, simpler to code, and quantitatively close to the alternative (one initial infection at an unknown time) because during an outbreak, new infections should be dominated by local internal infections.
:rtype: dict | ||
""" | ||
samples = super().predict(forecast) | ||
samples["first_infection"] = samples["I"].cumsum(-1).eq(0).sum(-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please comment on this quantity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Addreses #2426
This adds an
UnknownStartSIRModel
that models infections overpre_window + duration
many time steps. During the initialpre_window
-many steps there are zero observed infections but possible "spontaneous" infections from an external source, at a poisson rate of1 / pre_window
.To make this model realistic I've also assumed two different detection rates:
rho0
up until the first infection andrho1
thereafter. This new inhomogeneous functionality requires a newIndex(-)[-]
helper similar to our olderVindex(-)[-]
. I plan to follow this up with another model with heterogeneous parameters for both ofR0
andrho
, possibly following brownian motion; this model will make heavier use ofIndex(-)[-]
.Tested-
UnknownStartSIRModel
Index(-)[-]