Beispiel #1
0
model_WAVE2 = models.COVID19_SEIRD(
    initial_states, params, time_dependent_parameters={'Nc': policies_WAVE2})

# -------------------
# Simulate the models
# -------------------

out_WAVE1 = model_WAVE1.sim('2020-07-07',
                            start_date=start_calibration_WAVE1,
                            warmup=warmup,
                            N=args.n_samples,
                            draw_fcn=draw_fcn_WAVE1,
                            samples=samples_dict_WAVE1)
simtime_WAVE1, df_2plot_WAVE1 = output_to_visuals(
    out_WAVE1, ['H_in', 'H_tot', 'ICU', 'D', 'R'],
    args.n_samples,
    args.n_draws_per_sample,
    LL=conf_int / 2,
    UL=1 - conf_int / 2)

out_WAVE2 = model_WAVE2.sim('2021-02-01',
                            start_date=start_calibration_WAVE2,
                            warmup=0,
                            N=args.n_samples,
                            draw_fcn=draw_fcn_WAVE2,
                            samples=samples_dict_WAVE2)
simtime_WAVE2, df_2plot_WAVE2 = output_to_visuals(
    out_WAVE2, ['H_in', 'H_tot', 'ICU', 'D', 'R'],
    args.n_samples,
    args.n_draws_per_sample,
    LL=conf_int / 2,
    UL=1 - conf_int / 2)
Beispiel #2
0
                N=n_samples,
                draw_fcn=draw_fcn,
                samples=samples_dict)

# ------------------------------
# Function to add poisson draws
# ------------------------------

print('\n5) Adding a-posteriori uncertainty')

conf_int = 0.05
from covid19model.models.utils import output_to_visuals

simtime, df_2plot = output_to_visuals(out, ['H_in', 'H_tot', 'ICU', 'D', 'R'],
                                      n_samples,
                                      n_draws_per_sample,
                                      LL=conf_int / 2,
                                      UL=1 - conf_int / 2)

# -----------
# Visualizing
# -----------

print('\n6) Visualizing fit \n')

# Plot
fig, ax = plt.subplots(figsize=(10, 5))
# Incidence
ax.fill_between(pd.to_datetime(out['time'].values),
                df_2plot['H_in', 'LL'],
                df_2plot['H_in', 'UL'],
            for ldx, order in enumerate(orders):
                print('\t#### Vaccination order: ' + description_order[ldx])
                model.parameters.update({'vacc_order': order})
                # --------------
                # Simulate model
                # --------------
                out_vacc = model.sim(end_sim,
                                     start_date=start_sim,
                                     warmup=warmup,
                                     N=n_samples,
                                     draw_fcn=draw_fcn,
                                     samples=samples_dict)
                simtime, df_2plot = output_to_visuals(out_vacc,
                                                      ['H_in', 'H_tot'],
                                                      n_samples,
                                                      args.n_draws_per_sample,
                                                      LL=conf_int / 2,
                                                      UL=1 - conf_int / 2)
                # Append to dataframe
                columnnames = [
                    'incidences_mean', 'incidences_median', 'incidences_LL',
                    'incidences_UL', 'load_mean', 'load_median', 'load_LL',
                    'load_UL'
                ]
                data = [
                    df_2plot['H_in', 'mean'], df_2plot['H_in', 'median'],
                    df_2plot['H_in', 'LL'], df_2plot['H_in', 'UL'],
                    df_2plot['H_tot', 'mean'], df_2plot['H_tot', 'median'],
                    df_2plot['H_tot', 'LL'], df_2plot['H_tot', 'UL']
                ]
                for i in range(len(columnnames)):