Add npv_table for net present value of flow-variable changes - #1195
Open
arihantlodha-cmd wants to merge 1 commit into
Open
Add npv_table for net present value of flow-variable changes#1195arihantlodha-cmd wants to merge 1 commit into
arihantlodha-cmd wants to merge 1 commit into
Conversation
Closes PSLmodels#1131. Adds output_tables.npv_table, which builds a table of the net present value of the reform-minus-baseline change in flow variables (e.g. Y) over a horizon, evaluated at a list of discount rates. Values are un-stationarized by default so the NPV is taken over the actual level path, which is the economically meaningful object to discount; pass stationarized=True to use the stationarized model values instead. Adds a DataFrame test on the cached run output and an exactness test that checks the discounted sum against a hand calculation, plus a CHANGELOG entry.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1195 +/- ##
==========================================
+ Coverage 72.74% 72.85% +0.10%
==========================================
Files 22 22
Lines 5768 5791 +23
==========================================
+ Hits 4196 4219 +23
Misses 1572 1572
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1131.
Adds
output_tables.npv_table, which builds a table of the net present value of the reform-minus-baseline change in flow variables (e.g.Y) over a horizon, evaluated at a list of discount rates. For each variable:This follows the pattern the issue points to from the Cost of Disease repo, generalized into a reusable table function that fits the existing
output_tables.pyconventions (samebase_tpi/reform_tpi/*_paramssignature,VAR_LABELS, andsave_return_tablefor csv/tex/excel/json output).Design choices, flagged for review:
stationarized=Truekeeps the model values if a caller wants them. (This is why the default differs frommacro_table, which defaults to stationarized.)reform_tpiis asserted to be present.factorto the output dictionaries, a caller can scale by it for dollars; I left that to the caller rather than bake in a dollar-year assumption. Happy to add an optional dollar conversion if you'd prefer it built in.Output layout: one row per variable, one column per discount rate.
Testing
test_npv_tablebuilds the table from the cached run output and checks the shape.test_npv_table_valueschecks the discounted sum against a hand calculation at r = 0 and r = 0.1.pytest tests/test_output_tables.pypasses (21);ruff format --check .,ruff check ., andlinecheckclean.