Commit 09028419 authored by Peter Jentsch's avatar Peter Jentsch
Browse files

fit with fixed beta

parent 56dd216a
......@@ -15,15 +15,13 @@ function solve_w_parameters(default_p, p_names, new_p_list)
end
function fit_distribution_parameters(p_tuple)
p_names = (:ω,:β_y,:β_m,:β_o,:π_base_y,:π_base_m,:π_base_o)
p_names = (:ω,:π_base_y,:π_base_m,:π_base_o,:ζ)
priors = Factored(
Uniform(0.0,0.01),
Uniform(0.0,0.5),
Uniform(0.0,0.5),
Uniform(0.0,1.0),
Uniform(-5.0,3.0),
Uniform(-5.0,3.0),
Uniform(-5.0,3.0),
Uniform(-5.0,3.0),
Uniform(1.0,2.0),
)
#simulation begins in july
#60 days for opinion dynamics to stabilize, then immunization begins in september,
......@@ -61,15 +59,15 @@ function fit_distribution_parameters(p_tuple)
end
# display(cost((0.005,0.00075, 0.00063,0.75,-1.4,-1.4,-0.95)))
out = smc(priors,cost; verbose = true, nparticles = 1000, parallel = true)
out = smc(priors,cost; verbose = true, nparticles = 250, parallel = true)
return NamedTuple{p_names}(ntuple(i -> out.P[i].particles,length(p_names)))
end
function fit_parameters(default_parameters)
# pre_inf_behaviour_parameters_path =joinpath(PACKAGE_FOLDER,"abm_parameter_fits","pre_inf_behaviour_parameters.dat")
# post_inf_behaviour_parameters_path = joinpath(PACKAGE_FOLDER,"abm_parameter_fits","post_inf_behaviour_parameters.dat")
fit_all_parameters_path = joinpath(PACKAGE_FOLDER,"abm_parameter_fits","fit_all_parameters.dat")
# output = fit_distribution_parameters(default_parameters)
# serialize(fit_all_parameters_path,output)
output = fit_distribution_parameters(default_parameters)
serialize(fit_all_parameters_path,output)
fitted_parameter_tuple = deserialize(fit_all_parameters_path)
......@@ -88,13 +86,13 @@ function plot_fitting_posteriors(fname,particles_tuple,parameters)
avg_populations = [0.0,0.0,0.0]
names = keys(particles_tuple)
samples = collect(zip(particles_tuple...))
for p_set in sample(samples,1)
for p_set in sample(samples,30)
p_set_named = NamedTuple{names}(p_set)
sol = abm(merge(parameters,p_set_named),output_recorder)
avg_populations .+= length.(sol.index_vectors)
fit!(stat_recorder,output_recorder)
end
avg_populations ./= 1
avg_populations ./= 30
p = plot_model(nothing,[nothing],[stat_recorder],parameters.infection_introduction_day,parameters.immunization_begin_day)
savefig(p, "$fname.pdf")
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment