Closed cliffckerr closed 4 months ago
Closed by #330
I think the issue in agent_model.py is that the Susceptible population should be declining at a faster rate per standard SIR models.
`# Run the simulation for t in x[:-1]:
pop.check_infections() # Check which infectious occur
pop.check_recoveries() # Check which recoveries occur
#S[t+1] = pop.count_S() # Count the current number of susceptible people
I[t+1] = pop.count_I()
R[t+1] = pop.count_R()
# --> Update Susceptible Math <--
S[t+1] = N - I[t+1] - R[t+1] # Population - sum(Recovered) - sum(Infected*)
#*If Infected confers immunity or exclusion from the Susceptible population.
`
The tests/test_simple.py has a test_sir_epi() method method that generates objects: s0, s1 ->s3a, s3b (output in main)
Potential offending method: cum_infections() where s3a Infected array has all zero '0' values and s3b has incorrectly calculated Cumulative Infections. https://github.com/amath-idm/starsim/blob/a88795b0b39693b3e25b0f2d082d7d258f3d1b5d/tests/test_simple.py#L75C1-L86C52
Code in disease.py
def update_results(self, sim):
super().update_results(sim)
res = self.results
res['prevalence'][sim.ti] = res.n_infected[sim.ti] / np.count_nonzero(sim.people.alive)
>>>res['new_infections'][sim.ti] = np.count_nonzero(self.ti_infected == sim.ti)
res['cum_infections'][sim.ti] = np.sum(res['new_infections'][:sim.ti])
np.count_nonzero() will produce an integer value for the count of nonzero array elements given an array input of numbers (integer and/or float). However, self.ti_infected == sim.ti
this looks to evaluate as a boolean logical expression with output as an array of boolean values of True, False = 1, 0. I am not 100% if self.ti_infected and sim.ti are both arrays. This *may indicate why s3a generates Infected array values all equal to zero where all expressions evaluate as False.
Modifying the parameters of the SIR model, it's not behaving the way I'd expect. Some preliminary findings:
p_death=0.5
results in a handful of deaths out of 10k people, butp_death>1
leads to an exceptionprevalence
isn't being calculated incorrectly -- like people aren't being removed fromn_infected
when they recover?