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

Trend max steps #528

Merged
merged 12 commits into from
Oct 4, 2024
Merged

Trend max steps #528

merged 12 commits into from
Oct 4, 2024

Conversation

jamesturner246
Copy link
Contributor

@jamesturner246 jamesturner246 commented Sep 19, 2024

REVIEW AFTER #527

This change adds a new configurable TrendSteps value (must be defined for both the static (i.e. StaticLinear.json) and the dynamic (i.e. KevinHall.json) models).

This is used to ensure that the exponential trends in RiskFactorAdjustableModel and StaticLinearModelare capped after a defined number of elapsed time steps.

Resolves #517

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/HealthGPS/risk_factor_adjustable_model.cpp Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 52 lines in your changes missing coverage. Please review.

Project coverage is 49.00%. Comparing base (2f9e0b8) to head (4e30b49).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/HealthGPS.Input/model_parser.cpp 0.00% 17 Missing ⚠️
src/HealthGPS/risk_factor_adjustable_model.cpp 0.00% 12 Missing ⚠️
src/HealthGPS/static_linear_model.cpp 0.00% 9 Missing ⚠️
src/HealthGPS/kevin_hall_model.cpp 0.00% 8 Missing ⚠️
...rc/HealthGPS/dynamic_hierarchical_linear_model.cpp 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #528      +/-   ##
==========================================
- Coverage   49.12%   49.00%   -0.13%     
==========================================
  Files         164      164              
  Lines        7796     7816      +20     
  Branches     1062     1063       +1     
==========================================
  Hits         3830     3830              
- Misses       3957     3977      +20     
  Partials        9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jzhu20
Copy link
Contributor

jzhu20 commented Sep 19, 2024

It looks good to me.

@jamesturner246 jamesturner246 marked this pull request as ready for review September 23, 2024 11:08
Copy link
Contributor

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good to me, but I've got a few questions.

As I've merged #532 now, you'll need to merge in main and update the schemas to include the TrendSteps properties (sorry!).

@@ -44,7 +46,8 @@ double RiskFactorAdjustableModel::get_expected(RuntimeContext &context, core::Ge
// Apply optional trend to expected value.
if (apply_trend) {
int elapsed_time = context.time_now() - context.start_time();
expected *= pow(expected_trend_->at(factor), elapsed_time);
int t = std::min(elapsed_time, get_trend_steps(factor));
expected *= pow(expected_trend_->at(factor), t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the logic of this bit? It's puzzling me.

Copy link
Contributor Author

@jamesturner246 jamesturner246 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. t is the smaller of the number of elapsed years and the upper bound on elapsed years, used to bound the exponential growth. Maybe num_trend_steps is a better name.

So at the start, when elapsed <= trend_steps, we have expect_new = expect * trend^elapsed, but after we have expect_new = expect * trend^trend_steps.

Comment on lines +203 to +204
std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_trend,
std::unique_ptr<std::unordered_map<core::Identifier, int>> trend_steps)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in thinking that expected_trend and trend_steps will have the same keys? If so, would it make sense to just have the one map, with each value being a struct containing both of these values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind If I do this one later? Still not completely certain that a new bunch of vars won't be requested soon.

src/HealthGPS/risk_factor_adjustable_model.h Outdated Show resolved Hide resolved
@jamesturner246
Copy link
Contributor Author

I've opened #544 regarding the schema update. Sorry, should have done it here.

Copy link
Contributor

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're dealing with the schema thing in #544, I think this one is good to merge.

@jamesturner246 jamesturner246 merged commit 5721fe0 into main Oct 4, 2024
5 of 7 checks passed
@jamesturner246 jamesturner246 deleted the trend_max_steps branch October 4, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix time coefficient after 20 years
3 participants