Skip to content

Commit

Permalink
delete initialisation --- not used
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBrand1 committed Feb 27, 2024
1 parent a7e3d60 commit 1f5d461
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 85 deletions.
20 changes: 10 additions & 10 deletions EpiAware/src/EpiAware.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ This module provides functionality for calculating Rt (effective reproduction nu
module EpiAware

using Distributions,
Turing,
LogExpFunctions,
LinearAlgebra,
SparseArrays,
Random,
ReverseDiff,
Optim,
Parameters,
QuadGK,
DataFramesMeta
Turing,
LogExpFunctions,
LinearAlgebra,
SparseArrays,
Random,
ReverseDiff,
Optim,
Parameters,
QuadGK,
DataFramesMeta

# Exported utilities
export create_discrete_pmf, spread_draws
Expand Down
4 changes: 2 additions & 2 deletions EpiAware/src/epimodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ and `g_i` is the generation interval.
"""
function (epimodel::Renewal)(recent_incidence, Rt)
new_incidence = Rt * dot(recent_incidence, epimodel.data.gen_int)
return (
[new_incidence; recent_incidence[1:(epimodel.data.len_gen_int - 1)]], new_incidence)
return ([new_incidence; recent_incidence[1:(epimodel.data.len_gen_int - 1)]],
new_incidence)
end

function generate_latent_infs(epimodel::AbstractEpiModel, latent_process)
Expand Down
22 changes: 0 additions & 22 deletions EpiAware/src/initialisation.jl

This file was deleted.

3 changes: 1 addition & 2 deletions EpiAware/src/models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
observation_model::AbstractObservationModel,
pos_shift = 1e-6)
#Latent process
@submodel latent_process, latent_process_aux = generate_latent_process(
latent_process_model,
@submodel latent_process, latent_process_aux = generate_latent_process(latent_process_model,
time_steps)

#Transform into infections
Expand Down
20 changes: 10 additions & 10 deletions EpiAware/test/test_epimodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ end
@test ks_test_pval > 1e-6 #Very unlikely to fail if the model is correctly implemented

#Check that the generated incidence is correct given correct initialisation
mdl_incidence = generated_quantities(
EpiAware.generate_latent_infs(rt_model, rt), (init_incidence = log_init,))
mdl_incidence = generated_quantities(EpiAware.generate_latent_infs(rt_model, rt),
(init_incidence = log_init,))
@test mdl_incidence recent_incidence
end

Expand All @@ -98,8 +98,8 @@ end
expected_incidence = exp.(log_init_scale .+ log_incidence)

#Check log_init is sampled from the correct distribution
sample_init_inc = sample(
EpiAware.generate_latent_infs(direct_inf_model, log_incidence), Prior(), 1000) |>
sample_init_inc = sample(EpiAware.generate_latent_infs(direct_inf_model, log_incidence),
Prior(), 1000) |>
chn -> chn[:init_incidence] |>
Array |>
vec
Expand All @@ -108,8 +108,8 @@ end
@test ks_test_pval > 1e-6 #Very unlikely to fail if the model is correctly implemented

#Check that the generated incidence is correct given correct initialisation
mdl_incidence = generated_quantities(
EpiAware.generate_latent_infs(direct_inf_model, log_incidence),
mdl_incidence = generated_quantities(EpiAware.generate_latent_infs(direct_inf_model,
log_incidence),
(init_incidence = log_init_scale,))

@test mdl_incidence expected_incidence
Expand Down Expand Up @@ -139,8 +139,8 @@ end
initial_incidence = [1.0, 1.0, 1.0]#aligns with initial exp growth rate of 0.

#Check log_init is sampled from the correct distribution
@time sample_init_inc = sample(
EpiAware.generate_latent_infs(renewal_model, log_Rt), Prior(), 1000) |>
@time sample_init_inc = sample(EpiAware.generate_latent_infs(renewal_model, log_Rt),
Prior(), 1000) |>
chn -> chn[:init_incidence] |>
Array |>
vec
Expand All @@ -150,8 +150,8 @@ end

#Check that the generated incidence is correct given correct initialisation
#Check first three days "by hand"
mdl_incidence = generated_quantities(
EpiAware.generate_latent_infs(renewal_model, log_Rt), (init_incidence = 0.0,))
mdl_incidence = generated_quantities(EpiAware.generate_latent_infs(renewal_model,
log_Rt), (init_incidence = 0.0,))

day1_incidence = dot(initial_incidence, gen_int) * Rt[1]
day2_incidence = dot(initial_incidence, gen_int) * Rt[2]
Expand Down
32 changes: 0 additions & 32 deletions EpiAware/test/test_initialisation.jl

This file was deleted.

4 changes: 2 additions & 2 deletions EpiAware/test/test_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
Δd = Δd)

# Create full epi model and sample from it
test_mdl = make_epi_inference_model(
y_t, time_horizon; epimodel = epimodel, latent_process_model = rwp,
test_mdl = make_epi_inference_model(y_t, time_horizon; epimodel = epimodel,
latent_process_model = rwp,
observation_model = obs_model, pos_shift)
gen = generated_quantities(test_mdl, rand(test_mdl))

Expand Down
10 changes: 5 additions & 5 deletions EpiAware/test/test_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
@testset "Test case 5" begin
dist = Exponential(1.0)
expected_pmf_uncond = [exp(-1)
[(1 - exp(-1)) * (exp(1) - 1) * exp(-s) for s in 1:9]]
[(1 - exp(-1)) * (exp(1) - 1) * exp(-s) for s in 1:9]]
expected_pmf = expected_pmf_uncond ./ sum(expected_pmf_uncond)
pmf = create_discrete_pmf(dist; Δd = 1.0, D = 10.0)
@test expected_pmfpmf atol=1e-15
Expand Down Expand Up @@ -100,10 +100,10 @@ end
delay_int = [0.2, 0.5, 0.3]
time_horizon = 5
expected_K = SparseMatrixCSC([0.2 0 0 0 0
0.5 0.2 0 0 0
0.3 0.5 0.2 0 0
0 0.3 0.5 0.2 0
0 0 0.3 0.5 0.2])
0.5 0.2 0 0 0
0.3 0.5 0.2 0 0
0 0.3 0.5 0.2 0
0 0 0.3 0.5 0.2])
K = EpiAware.generate_observation_kernel(delay_int, time_horizon)
@test K == expected_K
end
Expand Down

0 comments on commit 1f5d461

Please sign in to comment.