Skip to content

Commit

Permalink
Merge pull request #546 from imperialCHEPI/ebhlm_trend_fix
Browse files Browse the repository at this point in the history
Handle missing trend vars in EBHLM.
  • Loading branch information
jamesturner246 authored Oct 7, 2024
2 parents f52b01e + ee8e11c commit 5079c9b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/HealthGPS.Input/model_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ load_ebhlm_risk_model_definition(const nlohmann::json &opt, const Configuration

auto info = LiteHierarchicalModelInfo{};

// Risk factor expected values by sex and age.
auto expected = load_risk_factor_expected(config);
auto expected_trend = std::make_unique<std::unordered_map<core::Identifier, double>>();
auto trend_steps = std::make_unique<std::unordered_map<core::Identifier, int>>();

auto percentage = 0.05;
opt["BoundaryPercentage"].get_to(info.percentage);
if (info.percentage > 0.0 && info.percentage < 1.0) {
Expand All @@ -424,6 +429,10 @@ load_ebhlm_risk_model_definition(const nlohmann::json &opt, const Configuration
info.variables = opt["Variables"].get<std::vector<VariableInfo>>();
for (const auto &item : info.variables) {
variables.emplace(hgps::core::Identifier{item.name}, hgps::core::Identifier{item.factor});

// NOTE: variable trending is not used in this model.
expected_trend->emplace(hgps::core::Identifier{item.factor}, 1.0);
trend_steps->emplace(hgps::core::Identifier{item.factor}, 0);
}

for (const auto &age_grp : info.equations) {
Expand Down Expand Up @@ -464,11 +473,6 @@ load_ebhlm_risk_model_definition(const nlohmann::json &opt, const Configuration
equations.emplace(age_key, std::move(age_equations));
}

// Risk factor expected values by sex and age.
auto expected = load_risk_factor_expected(config);
auto expected_trend = std::make_unique<std::unordered_map<core::Identifier, double>>();
auto trend_steps = std::make_unique<std::unordered_map<core::Identifier, int>>();

return std::make_unique<hgps::DynamicHierarchicalLinearModelDefinition>(
std::move(expected), std::move(expected_trend), std::move(trend_steps),
std::move(equations), std::move(variables), percentage);
Expand Down

0 comments on commit 5079c9b

Please sign in to comment.