Skip to content

Commit

Permalink
Replicate existing channels pattern for storing which stats to calc
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyMarsh committed Jul 2, 2024
1 parent 257fe6c commit 0ed3f94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
48 changes: 34 additions & 14 deletions src/HealthGPS/analysis_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,9 @@ void AnalysisModule::initialise_vector(RuntimeContext &context) {
// `factors` vector.
size_t num_stats_to_calc = context.mapping().entries().size() - factors_to_calculate_.size();

// But we calculate the mean and standard deviation of each factor, so we need to multiply by 2
num_stats_to_calc *= 2;

// We also want to calculate the prevalence and incidence of each disease
num_stats_to_calc += 2 * context.diseases().size();

// We also want to keep the count, deaths, and emigrations
num_stats_to_calc += 3;

// We also want to calculate the normal, overweight, obese, and above weight prevalence
num_stats_to_calc += 4;

// Finally, we want to calculate the mean and standard deviation of YLL, YLD, and DALY
num_stats_to_calc += 6;
// And for each factor, we calculate the stats described in `stats_to_calculate_`, so we
// multiply the number of stats to calculate by the number of factors to calculate stats for.
num_stats_to_calc *= stats_to_calculate_.size();

// The product of the number of bins for each factor can be used to calculate the size of the
// `calculated_stats_` in the next step
Expand Down Expand Up @@ -573,6 +562,37 @@ void AnalysisModule::initialise_output_channels(RuntimeContext &context) {
channels_.emplace_back("std_daly");
}

void AnalysisModule::initialise_stats_to_calc(RuntimeContext &context) {

Check failure on line 565 in src/HealthGPS/analysis_module.cpp

View workflow job for this annotation

GitHub Actions / Build and test (linux, ubuntu-22.04, gcc-latest, false)

no declaration matches ‘void hgps::AnalysisModule::initialise_stats_to_calc(hgps::RuntimeContext&)’

Check failure on line 565 in src/HealthGPS/analysis_module.cpp

View workflow job for this annotation

GitHub Actions / Build and test (linux, ubuntu-22.04, gcc-latest, false)

no declaration matches ‘void hgps::AnalysisModule::initialise_stats_to_calc(hgps::RuntimeContext&)’
if (!stats_to_calculate_.empty()) {
return;
}

stats_to_calculate_.push_back("count");
stats_to_calculate_.push_back("deaths");
stats_to_calculate_.push_back("emigrations");

for (const auto &factor : context.mapping().entries()) {
stats_to_calculate_.push_back("mean_" + factor.key().to_string());
stats_to_calculate_.push_back("std_" + factor.key().to_string());
}

for (const auto &disease : context.diseases()) {
stats_to_calculate_.push_back("prevalence_" + disease.code.to_string());
stats_to_calculate_.push_back("incidence_" + disease.code.to_string());
}

stats_to_calculate_.push_back("normal_weight");
stats_to_calculate_.push_back("over_weight");
stats_to_calculate_.push_back("obese_weight");
stats_to_calculate_.push_back("above_weight");
stats_to_calculate_.push_back("mean_yll");
stats_to_calculate_.push_back("std_yll");
stats_to_calculate_.push_back("mean_yld");
stats_to_calculate_.push_back("std_yld");
stats_to_calculate_.push_back("mean_daly");
stats_to_calculate_.push_back("std_daly");
}

std::unique_ptr<AnalysisModule> build_analysis_module(Repository &repository,
const ModelInput &config) {
auto analysis_entity = repository.manager().get_disease_analysis(config.settings().country());
Expand Down
1 change: 1 addition & 0 deletions src/HealthGPS/analysis_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AnalysisModule final : public UpdatableModule {
WeightModel weight_classifier_;
DoubleAgeGenderTable residual_disability_weight_;
std::vector<std::string> channels_;
std::vector<std::string> stats_to_calculate_;
unsigned int comorbidities_;
std::string name_{"Analysis"};
std::vector<core::Identifier> factors_to_calculate_ = {"Gender"_id, "Age"_id};
Expand Down

0 comments on commit 0ed3f94

Please sign in to comment.