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

[Feature] Add a Life extractor #8

Merged
merged 16 commits into from
May 16, 2024
Merged

[Feature] Add a Life extractor #8

merged 16 commits into from
May 16, 2024

Conversation

lrnv
Copy link
Member

@lrnv lrnv commented Apr 10, 2024

No description provided.

@lrnv lrnv linked an issue May 14, 2024 that may be closed by this pull request
@lrnv lrnv changed the title Adding a life function, untested Add Life random variables extracted from a rate table May 14, 2024
Copy link
Member Author

@lrnv lrnv left a comment

Choose a reason for hiding this comment

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

I have an issue that is that

julia> L = Life(slopop[:male], 7000, 1940*365.241)
Life(
∂t: [5.093170329928398e-11, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488    60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488, 60.42100000005121, 304.8199999999488]
λ: [1.18259308900975e-5, 1.18259308900975e-5, 1.31461386213319e-5, 1.31461386213319e-5, 1.43568885285431e-5, 1.43568885285431e-5, 1.52653024528616e-5, 1.52653024528616e-5, 1.59261564872642e-5, 1.59261564872642e-5    0.000952040196524071, 0.000733071745918347, 0.000660281996864776, 0.00105021724521249, 0.00123749831958367, 0.00112796698379798, 0.000624953529261446, 0.00105591234503242, 0.00111013031972907, 0.000734484865047132]       
)


julia> expectation(L)/265.241
67.35108708597433

which is OK, but

julia> L = Life(slopop[:male], 7000, 1990*365.241)
Life(
∂t: [3.637978807091713e-12, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607    60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607, 60.421000000003914, 304.81999999999607]
λ: [5.5910580526963e-6, 3.17782866861003e-6, 3.45195218341532e-6, 4.76812723189004e-6, 4.60357074517423e-6, 3.39712528476538e-6, 3.45195218341532e-6, 4.1922227932534e-6, 5.20699288852109e-6, 4.21964406742172e-6    4.38476258334695e-6, 5.32225320572007e-6, 7.32946027661339e-6, 6.63278668692437e-6, 7.52554010487343e-6, 4.17886868465e-6, 8.4691237966412e-6, 6.39964683932395e-6, 9.31110361684609e-6, 9.953004363499262e-6]
)


julia> expectation(L)/265.241
41.55705546700694

i.e. people youger have a life expectation that goes up to today and then they are out.
maybe we need to do something w.r.t. the remaining survival at the end of tha table ? This might be one of the reason our numbers do not reconciles with R. But then the question is how do they correct for this in R ?

Edit : 265 instead of 365 but same conclusion

@lrnv lrnv changed the title Add Life random variables extracted from a rate table [Feature] Add a Life extractor May 15, 2024
@lrnv
Copy link
Member Author

lrnv commented May 15, 2024

With the last modifications this should be good to go. Todo before merging :

  • Document the functionality correctly. Basically it allows to extract a life (given covaraites) from a ratetable and then use this life as a random variables: survival, expectation, random number generation, etc... We should add doctrings but also add a part on the online docs about the functionality.
  • Merge and register a new version fo the package.

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 77.19298% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 73.68%. Comparing base (136610f) to head (c041c48).
Report is 6 commits behind head on main.

Files Patch % Lines
src/Life.jl 77.19% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   70.17%   73.68%   +3.50%     
==========================================
  Files           3        4       +1     
  Lines          57      114      +57     
==========================================
+ Hits           40       84      +44     
- Misses         17       30      +13     

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

Copy link
Member Author

@lrnv lrnv left a comment

Choose a reason for hiding this comment

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

Yep, looks good to me. However it lacks a test to be good to go. Only a test that enforces the syntax of calling it.

Copy link
Member Author

@lrnv lrnv left a comment

Choose a reason for hiding this comment

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

let me write up the test quickly

Copy link
Member Author

@lrnv lrnv left a comment

Choose a reason for hiding this comment

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

@rimhajal If online tests passes, this should be good to go. As soon as it is merged, we have to register the new version

@rimhajal rimhajal merged commit 6709d48 into main May 16, 2024
5 checks passed
@rimhajal rimhajal deleted the test_life branch May 16, 2024 13:59
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.

[Feature] Get lifes
2 participants