resplab / epicR

R package for the Evaluation Platform in COPD (EPIC), an agent-based whole-disease model for projection of health and economic outcomes and COPD interventions.
11 stars 11 forks source link

population: 1 million more in epicR every year #54

Closed aminadibi closed 6 years ago

aminadibi commented 6 years ago

validate_population in epicR v0.15.2 produces this:

image

Which comes from this data:

Here's simulated vs. predicted population table:
     Year Predicted Simulated
2015 2015  18179400  19136963
2016 2016  18428900  19357094
2017 2017  18676400  19585726
2018 2018  18925000  19821518
2019 2019  19179600  20058891
2020 2020  19444400  20306885
2021 2021  19715800  20560254
2022 2022  19981100  20818775
2023 2023  20248700  21083007
2024 2024  20516200  21350884
2025 2025  20784000  21623635
2026 2026  21046600  21899621
2027 2027  21298900  22173990
2028 2028  21546300  22453846
2029 2029  21803400  22738946
2030 2030  22073100  23034035
2031 2031  22338900  23322503
2032 2032  22597100  23616662
2033 2033  22847900  23912011
2034 2034  23091200  24214838
aminadibi commented 6 years ago

Seems we have incidence population in the first year, which should not be the case really

aminadibi commented 6 years ago

Trying to make incidence = 0 for the first year of the model.

Setting this:

    if (output.n_agents>settings.n_base_agents)  //now we are done with prevalent cases and are creating incident cases;
      {
      double incidence = 0;
      if (calendar_time != 0) {
        incidence = exp(input.agent.l_inc_betas[0]+input.agent.l_inc_betas[1]*calendar_time+input.agent.l_inc_betas[2]*calendar_time*calendar_time);
      }
      if(incidence<0.000000000000001) calendar_time=input.global_parameters.time_horizon; else calendar_time=calendar_time+1/(incidence*settings.n_base_agents);
      }
    last_id++;

Resulted in: image

and

image

The first year seems to be matched, which is what we expected. Interesting though that the remainder looks so weird.

aminadibi commented 6 years ago

What does this do? if(incidence<0.000000000000001) calendar_time=input.global_parameters.time_horizon; else calendar_time=calendar_time+1/(incidence*settings.n_base_agents);

aminadibi commented 6 years ago

problem solved.

The issue was that in order to prevent double population in the first year, we were suppressing prevalence and let incidence create all first year agents. Reversing that fixed the problem:

    if (output.n_agents>settings.n_base_agents)  //now we are done with prevalent cases and are creating incident cases;
      {
       double incidence = exp(input.agent.l_inc_betas[0]+input.agent.l_inc_betas[1]*calendar_time+input.agent.l_inc_betas[2]*calendar_time*calendar_time);
      if(incidence<0.000000000000001) calendar_time=input.global_parameters.time_horizon; else {
        if (calendar_time!=0) calendar_time=calendar_time+1/(incidence*settings.n_base_agents); else calendar_time=calendar_time+1; //suprresing incidence cases in the first year
      }
      }
    last_id++;

image

image