Skip to content

Joint and single-stream models ​

The composers that assemble the submodels into a fittable model. bvd_joint is the headline fit over every included stream. The *_only_model composers fit one stream at a time for the stream-by-stream comparison.

Index ​

Reference ​

BVDOutbreakSize.bvd_joint Function
julia
bvd_joint(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer};
    ...
) -> Any
bvd_joint(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer},
    reported_cases::Union{Missing, Integer};
    ...
) -> Any
bvd_joint(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer},
    reported_cases::Union{Missing, Integer},
    exports_deaths::Union{Missing, Integer};
    ...
) -> Any
bvd_joint(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer},
    reported_cases::Union{Missing, Integer},
    exports_deaths::Union{Missing, Integer},
    confirmed_cases::Union{Missing, Integer};
    ...
) -> Any
bvd_joint(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer},
    reported_cases::Union{Missing, Integer},
    exports_deaths::Union{Missing, Integer},
    confirmed_cases::Union{Missing, Integer},
    tests_analysed::Union{Missing, Integer};
    n_patches,
    importation_kernel,
    confirmed_deaths,
    recovered_cases,
    deaths_history,
    reported_history,
    confirmed_history,
    confirmed_deaths_history,
    lab_history,
    lab_daily_history,
    suspected_daily_history,
    suspected_daily_deaths_history,
    isolation_history,
    bed_capacity_history,
    recovered_history,
    treatment_admissions_history,
    treatment_deaths_history,
    treatment_ruleout_history,
    treatment_absconded_history,
    treatment_confirmed_incare_history,
    treatment_suspect_incare_history,
    occupancy_break_days,
    confirmed_break_days,
    confirmed_break_gross_cases,
    confirmed_break_gross_deaths,
    confirmed_break_sd,
    export_case_days,
    export_death_days,
    onset_curve_history,
    breakpoint,
    source_population,
    patch_infection,
    composition,
    province_increments,
    province_days,
    province_lab_increments,
    province_lab_days,
    province_lab_bins,
    lab_composition,
    background_split,
    province_isolation,
    province_capacity,
    province_admissions,
    province_death_increments,
    province_death_days,
    death_composition,
    death_ascertainment_sd_prior,
    province_cfr_sd_prior,
    export_pressure,
    exports,
    deaths,
    cases,
    confirmed,
    confirmed_deaths_stream,
    treatment,
    recovered,
    onset_report,
    dispersion,
    ascertainment,
    background_pooling,
    genetic,
    onset_to_sample,
    tmrca_days,
    tmrca_days_sd,
    renewal_start_lead,
    rt_walk_lead,
    background_onset_lead,
    treatment_defaults,
    forecast,
    simulated_data
) -> Any

Joint composer over all data streams. Runs the generating infection process once on a daily grid of length n (day n is the cut-off), stages it to daily onset incidence, then conditions on the DRC suspected cases, deaths and the laboratory pipeline, the confirmed deaths, the Uganda exports and deaths-among-exports, the digitised symptom-onset reporting triangle (onset_reporting_model, the only direct observation of the shared onset series, a no-op when onset_curve_history is empty), and the optional genetic seeding bound on the outbreak age. Each stream argument may be missing to drop it, so the model doubles as a prior- and posterior-predictive generator.

The confirmed-case stream shares its onset-to-report kernel with the suspected-case stream. A single analysed-specimen volume is fit through a report-to-analysed delay and the tested fraction. The confirmed positives are scored as a Binomial of the observed specimens-analysed denominator (lab_history) with a partially-pooled per-window positivity, so they do not pass through the multiplicative ascertainment ridge. After the national cumulative analysed series stops, the reporting format gives a 24h analysed count on some days (lab_daily_history). Those are fitted as per-day analysed volumes and also anchor that day's confirmed positives. Windows with no published denominator use the modelled analysed volume as the denominator, with the positivity (hence λ_bg) carried over from the windows that do have data (see confirmed_cases_model).

The optional suspected_daily_history adds the post-26 May daily new-suspect inflow ("nouveaux cas suspects du jour"), scored against the modelled daily suspected series on the report days where the frozen cumulative suspected stream stops, disjoint from it. The optional suspected_daily_deaths_history adds the deaths analogue, the daily new suspected deaths ("cas suspects du jour N (M deces)").

The confirmed deaths mirror the confirmed-case laboratory pipeline. A death "analysed" volume (the suspected deaths carried to laboratory receipt and scaled by the death testing intensity tau_death, specimens per suspected death, which may exceed one) is scored through a death-pool composition positivity p = s·q_death + (1−spec)(1−q_death), with q_death the BVD share of the suspected deaths (see confirmed_deaths_model). The suspected deaths carry a death ascertainment p_death and a non-BVD background tied to the case background by a background CFR cfr_bg (see deaths_model).

The optional isolation_history adds the daily isolation/treatment-bed occupancy ("Patients en isolement"), a prevalence stream fitted as the suspect inflow (BVD treatment stay plus non-BVD rule-out stay) carried through a length-of-stay survival into a daily stock (see treatment_flow_model). The optional recovered_history adds the recovered-among-confirmed stream ("cumul guéris"), survivors among the modelled daily confirmed cases scaled by the recovery probability and lagged by a confirmation-to-recovery delay (see recovered_model).

breakpoint is the intervention day passed to the reproduction-number walk (e.g. the first WHO situation report). genetic injects the genetic seeding submodel when tmrca_days is given. The analysed volume is scaled by specimens analysed per suspect (specimen_intensity_model), which τ_test alone, being a probability, cannot exceed one of.

Tracked deterministics: C_T (cumulative infections by the cut-off), the established reproduction number R0 (= the first R_t), r and doubling_time (current growth), r0 (the R0-implied cryptic growth rate), T (outbreak age), R_T (current reproduction number), the per-stream expected counts, the testing fraction tau_test, the specimens analysed per suspect (specimens_per_suspect), the background rate lambda_bg, the death ascertainment death_ascertainment, the background CFR background_cfr, the death testing intensity tau_death, the implied per-suspected (suspected_positivity) and per-test (test_positivity) positivities, and the death-pool BVD composition (death_composition) and death-confirmation positivity (death_confirmation).

With n_patches > 1 the latent process is the meta-population renewal of patch_infection_model, one renewal equation per province coupled by importation, with every national stream above fitted against the summed provinces. The default n_patches = 1 collapses it onto the single-population model, since the sum-to-zero deviations vanish, there is nothing to import between, and no per-province likelihood is scored.

The spatial information enters through two composition terms. The per-province confirmed cases and confirmed deaths in the situation reports' spatial tables are exact partitions of the national totals, so scoring them with their own count likelihoods would put the same data into the joint density twice. province_composition_model scores each split conditional on the national total instead, adding only the spatial signal the national series does not carry. Pass the reshaped data as province_increments with province_days, and province_death_increments with province_death_days, both built by province_increment_matrix. Omit them and the composition terms are skipped. The case composition identifies only the product of a province's incidence and its case-finding. The death composition identifies the incidence split, since the case-fatality ratio and the death-confirmation probability are national, and the case composition then identifies the relative case ascertainment as the residual.

A third composition scores the per-province analysed-specimen volume conditional on the national total in each laboratory bin. The modelled split is each patch's BVD suspects (its onsets through the onset-to-confirmation kernel, thinned by p_drc) plus its share of the non-BVD background, the share a partially pooled simplex (background_split_model) carries and this term identifies. The BVD suspects carry the case composition's relative ascertainment, so the two compositions agree on how many of a patch's cases reach the laboratory. Pass province_lab_increments with province_lab_days and province_lab_bins, built by province_lab_increment_matrix, which sums the printed days into calendar weeks for the production fit. The testing fraction stays national and the composition samples no ascertainment contrast of its own. The per-province positives are not fitted, being the differencing of the confirmed counts already scored.

Uganda exports are driven by the provinces in proportion to sampled relative export weights, with Ituri the reference at weight one (see province_export_pressure_model).

Per-patch quantities are surfaced as vector deterministics, one entry per patch, for patch_summary_table and patch_overview_table: C_T_patch, R_T_patch, infections_T_patch, delta_patch, log_rt_contrast and the deviation knots delta_knots from which reconstruct_patch_rt rebuilds the provincial trajectories. R_T is the force-of-infection-weighted reproduction number implied by the summed patch infections.

With forecast a ForecastHorizon (see with_horizon) the model runs past the cut-off n and draws each stream's future counts through its own likelihood, as missing observations predict generates: forecast_reports, forecast_deaths, forecast_confirmed, forecast_confirmed_deaths, forecast_recovered, the treatment flows (treatment_forecast_model), forecast_exports and the onset triangle's future vintages (onset_forecast_model). With province data, each future week's national confirmed cases and deaths are split across the provinces by the fitted compositions (composition_split_model), as forecast_province_confirmed and forecast_province_deaths. With province care data, the occupancy and admissions are drawn daily by province, as forecast_isolation.province.obs and forecast_admissions.province.obs, with the beds as forecast_province_beds, and each sums to the national forecast (treatment_forecast_model). Every quantity up to the cut-off, and the density there, is the fitted model's.

source
BVDOutbreakSize.cases_only_model Method
julia
cases_only_model(
    n::Integer,
    reported_cases::Union{Missing, Integer};
    reported_history,
    suspected_daily_history,
    breakpoint,
    infection,
    onset_incidence,
    cases,
    dispersion,
    ascertainment,
    forecast
) -> Any

Cases-only composer (reported-cases ascertainment). Runs the infection process and onset staging, samples dispersion and pooled ascertainment, then conditions on the reported-cases likelihood. See reported_cases_model.

source
BVDOutbreakSize.confirmed_deaths_only_model Function
julia
confirmed_deaths_only_model(
    n::Integer,
    confirmed_deaths::Union{Missing, Integer};
    ...
) -> Any
confirmed_deaths_only_model(
    n::Integer,
    confirmed_deaths::Union{Missing, Integer},
    total_deaths::Union{Missing, Integer};
    deaths_history,
    confirmed_deaths_history,
    confirmed_break_days,
    confirmed_break_gross_deaths,
    confirmed_break_sd,
    breakpoint,
    infection,
    onset_incidence,
    deaths,
    cases,
    confirmed_deaths_stream,
    dispersion,
    ascertainment,
    forecast
) -> Any

Confirmed-deaths-only composer. Runs the infection process and onset staging, samples dispersion and pooled ascertainment, runs the reported- cases stream (in predictive mode, to supply the non-BVD background the death background is scaled from) and the suspected-deaths stream, then conditions on the confirmed-death likelihood alone. See confirmed_deaths_model.

source
BVDOutbreakSize.confirmed_only_model Method
julia
confirmed_only_model(
    n::Integer,
    confirmed_cases::Union{Missing, Integer};
    confirmed_history,
    lab_history,
    lab_daily_history,
    tests_analysed,
    breakpoint,
    confirmed_break_days,
    confirmed_break_gross_cases,
    confirmed_break_sd,
    infection,
    onset_incidence,
    cases,
    confirmed,
    dispersion,
    ascertainment,
    forecast
) -> Any

Confirmed-cases-only composer (laboratory pipeline in isolation). Runs the infection process and onset staging, samples dispersion and pooled ascertainment, then runs the suspected-case stream in predictive mode (to draw the shared background rate, testing fraction and onset-to-report kernel) and conditions on the laboratory pipeline alone. That is the confirmed positives, a Binomial of the observed analysed denominator in lab_history, and the modelled analysed-specimen volume. See confirmed_cases_model and reported_cases_model.

Exposes the cut-off expected confirmed count as expected_confirmed_T, the same un-prefixed name bvd_joint uses. With forecast it draws the confirmed counts past the cut-off as forecast_confirmed, the future draws forecast_stream reads.

source
BVDOutbreakSize.deaths_only_model Method
julia
deaths_only_model(
    n::Integer,
    total_deaths::Union{Missing, Integer};
    deaths_history,
    suspected_daily_deaths_history,
    breakpoint,
    infection,
    onset_incidence,
    deaths,
    dispersion,
    forecast
) -> Any

Deaths-only composer (back-calculation analogue). Runs the infection process and onset staging, samples dispersion, then conditions on the deaths likelihood only. See deaths_model.

source
BVDOutbreakSize.exports_deaths_only_model Method
julia
exports_deaths_only_model(
    n::Integer,
    exports_deaths::Union{Missing, Integer};
    export_death_days,
    breakpoint,
    source_population,
    infection,
    onset_incidence,
    deaths,
    exports,
    dispersion,
    ascertainment
) -> Any

Deaths-among-exports-only composer. Runs the infection process and onset staging, samples ascertainment and the deaths submodel (for the CFR and onset-to-death delay), then conditions on the export-deaths likelihood. See exports_deaths_model.

source
BVDOutbreakSize.exports_joint_only_model Method
julia
exports_joint_only_model(
    n::Integer,
    exported_cases::Union{Missing, Integer},
    exports_deaths::Union{Missing, Integer};
    export_case_days,
    export_death_days,
    breakpoint,
    source_population,
    infection,
    onset_incidence,
    deaths,
    exports,
    dispersion,
    ascertainment,
    forecast
) -> Any

Exports-joint composer. The Uganda export cases and deaths fit together as one geographic-spread stream. Runs the infection process and onset staging, samples ascertainment and the deaths submodel (for the CFR and onset-to-death delay), then conditions on both the export-case and export-death likelihoods over the one travel-gated at-risk prevalence, so the two inform the outbreak size jointly. Either count may be missing to drop it. See exports_model and exports_deaths_model.

source
BVDOutbreakSize.exports_only_model Method
julia
exports_only_model(
    n::Integer,
    exported_cases::Union{Missing, Integer};
    export_case_days,
    breakpoint,
    source_population,
    infection,
    onset_incidence,
    exports,
    ascertainment
) -> Any

Exports-only composer (geographic-spread analogue). Runs the infection process and onset staging, samples ascertainment, then conditions on the exports likelihood only. See exports_model.

source
BVDOutbreakSize.forecast_days Method
julia
forecast_days(n::Integer, forecast) -> Any

Grid days a forecast covers past the cut-off n, n + 1 to n + horizon.

source
BVDOutbreakSize.onsets_only_model Method
julia
onsets_only_model(
    n::Integer;
    onset_curve_history,
    breakpoint,
    infection,
    onset_incidence,
    onset_report,
    forecast
) -> Any

Onsets-only composer (the direct-observation analogue). Runs the infection process and onset staging, then conditions on the symptom-onset reporting- triangle likelihood alone. See onset_reporting_model for the delay hazard, calendar-time drift, right-truncation and ascertainment maths.

This stream needs no dispersion submodel of its own. onset_report samples its own ascertainment level and is the only injected submodel. No confirmed pipeline is available to anchor ascertainment on, so it falls back to its constant 0.15 anchor.

Exposes the cut-off expected onset-reported count as expected_onset_reported_T, the un-prefixed name bvd_joint uses, and the modelled ascertainment as onset_ascertainment. With forecast it draws future vintages of the triangle (onset_forecast_model). Those future draws and the shared cumulative_onsets trajectory from _latent are what forecast_onsets reads, so this fit nowcasts and forecasts the onset stream, scored on the reported increment rather than on the digitised level.

source
BVDOutbreakSize.treatment_only_model Method
julia
treatment_only_model(
    n::Integer;
    isolation_history,
    bed_capacity_history,
    treatment_admissions_history,
    treatment_deaths_history,
    treatment_ruleout_history,
    treatment_absconded_history,
    treatment_confirmed_incare_history,
    treatment_suspect_incare_history,
    confirmed_history,
    confirmed_cases,
    lab_history,
    lab_daily_history,
    tests_analysed,
    occupancy_break_days,
    confirmed_break_days,
    confirmed_break_gross_cases,
    confirmed_break_sd,
    breakpoint,
    infection,
    onset_incidence,
    cases,
    confirmed,
    treatment,
    cfr,
    dispersion,
    ascertainment,
    treatment_defaults,
    forecast
) -> Any

Isolation-occupancy-only composer (treatment-bed prevalence in isolation). Runs the infection process and onset staging, samples dispersion and pooled ascertainment, then runs the suspected-case stream in predictive mode (to draw the shared background rate, testing fraction and onset-to-report kernel) and conditions on the isolation/treatment-bed occupancy alone. See treatment_flow_model and reported_cases_model.

source
BVDOutbreakSize.default_breakpoint Method
julia
default_breakpoint(obs) -> Any
julia
default_breakpoint(obs) -> Any

Intervention day index for a load_observations() result: the day the WHO published its first situation report, counted back from the grid end.

source
BVDOutbreakSize.joint_fit_args Method
julia
joint_fit_args(obs; breakpoint)
julia
joint_fit_args(obs; breakpoint)

Keyword arguments shared by every production bvd_joint fit, built from a load_observations() result.

breakpoint is the intervention day index.

See also patch_fit_args, which adds the spatial structure.

source
BVDOutbreakSize.patch_fit_args Method
julia
patch_fit_args(
    obs
) -> NamedTuple{(:n_patches, :province_increments, :province_days, :province_death_increments, :province_death_days, :province_lab_increments, :province_lab_days, :province_lab_bins, :province_isolation, :province_capacity, :province_admissions), <:Tuple{Int64, Matrix{Int64}, Any, Matrix{Int64}, Any, Any, Any, Any, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}}}
julia
patch_fit_args(
    obs
) -> NamedTuple{(:n_patches, :province_increments, :province_days, :province_death_increments, :province_death_days, :province_lab_increments, :province_lab_days, :province_lab_bins, :province_isolation, :province_capacity, :province_admissions), <:Tuple{Int64, Matrix{Int64}, Any, Matrix{Int64}, Any, Any, Any, Any, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}, NamedTuple{(:days, :patches, :counts), <:Tuple{Vector{Int64}, Any, Any}}}}

Spatial keyword arguments for the headline patch fit, built from a load_observations() result. The single-population control passes joint_fit_args without these.

The per-province tables are reshaped here rather than in the model body: the lookup goes by province name through a Dict{String}, and a string compare on the AD tape is a memcmp foreigncall Mooncake has no rule for, which aborts the gradient of the whole joint.

source
BVDOutbreakSize.production_joint Method
julia
production_joint(obs; breakpoint)
julia
production_joint(obs; breakpoint)

The headline bvd_joint model, for a load_observations() result.

This is the call the precompile workload compiles and the headline fit samples, so both reach Mooncake as the same method instance.

source