Skip to content
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

Submodels take kwargs variable splits rather than NamedTuples. #65

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EpiAware/src/latent-processes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ function default_rw_priors()
)
end

@model function random_walk(n; latent_process_priors = default_rw_priors())
@model function random_walk(n; var_RW_dist, init_rw_value_dist)
ϵ_t ~ MvNormal(ones(n))
σ²_RW ~ latent_process_priors.var_RW_dist
init ~ latent_process_priors.init_rw_value_dist
σ²_RW ~ var_RW_dist
init ~ init_rw_value_dist
σ_RW = sqrt(σ²_RW)
rw = Vector{eltype(ϵ_t)}(undef, n)

Expand Down
6 changes: 3 additions & 3 deletions EpiAware/src/models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
time_steps = epimodel.data.time_horizon
@submodel latent_process, init, latent_process_aux = latent_process_obj.latent_process(
time_steps;
latent_process_priors = latent_process_obj.latent_process_priors
latent_process_obj.latent_process_priors...
)

#Transform into infections
Expand All @@ -20,8 +20,8 @@
y_t,
I_t,
epimodel::AbstractEpiModel;
observation_process_priors = observation_process_obj.observation_model_priors,
pos_shift = pos_shift
pos_shift = pos_shift,
observation_process_obj.observation_model_priors...
)

#Generate quantities
Expand Down
6 changes: 3 additions & 3 deletions EpiAware/src/observation-processes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ end
y_t,
I_t,
epimodel::AbstractEpiModel;
observation_process_priors = default_delay_obs_priors(),
pos_shift = 1e-6
neg_bin_cluster_factor_prior,
pos_shift
)
#Parameters
neg_bin_cluster_factor ~ observation_process_priors.neg_bin_cluster_factor_prior
neg_bin_cluster_factor ~ neg_bin_cluster_factor_prior

#Predictive distribution
case_pred_dists = (epimodel.data.delay_kernel * I_t) .+ pos_shift .|>
Expand Down
3 changes: 2 additions & 1 deletion EpiAware/test/test_latent-processes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@testitem "Testing random_walk against theoretical properties" begin
using DynamicPPL, Turing
n = 5
model = EpiAware.random_walk(n)
priors = EpiAware.default_rw_priors()
model = EpiAware.random_walk(n; priors...)
fixed_model = fix(model, (σ²_RW = 1.0, init_rw_value = 0.0)) #Fixing the standard deviation of the random walk process
n_samples = 1000
samples_day_5 = sample(fixed_model, Prior(), n_samples) |>
Expand Down
5 changes: 3 additions & 2 deletions EpiAware/test/test_observation-processes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
data = EpiData([0.2, 0.3, 0.5], [1.0], 0.8, 3, exp)
epimodel = DirectInfections(data)
# Set up priors
observation_process_priors = default_delay_obs_priors()
priors = default_delay_obs_priors()

# Call the function
mdl = EpiAware.delay_observations(
missing,
I_t,
epimodel;
observation_process_priors = observation_process_priors
pos_shift = 1e-6,
priors...
)
fix_mdl = fix(mdl, neg_bin_cluster_factor = 0.00001) # Effectively Poisson sampling

Expand Down
Loading