PolicyEngine / PolicyEngine/policyengine-core

Add parameter extension functionality for uprating factors

Open
#391 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
22
Forks
30
Avg merge
14h 33m
Merged PRs (30d)
7

Description

Summary

Currently, each country package (e.g., policyengine-us) needs to implement its own logic for extending uprating factors beyond the last year of official projections. This is a common pattern that would benefit from being standardized in policyengine-core.

Proposed Feature

Add a utility function to policyengine-core that can programmatically extend parameter values based on a growth rate calculated from the last years of available data. This would:

  1. Calculate growth rate from the last N years of projections
  2. Apply that growth rate to extend values through a specified end year
  3. Handle different period types (monthly, yearly, etc.)

Example Usage

from policyengine_core.parameters import extend_parameter_values

# Extend a parameter through 2100 using growth from last 2 years
extend_parameter_values(
    parameter=parameters.gov.some.uprating,
    last_projected_year=2034,
    end_year=2100,
    period_month=10,  # For October values
    period_day=1,
)

Benefits

  • Consistent approach across country packages
  • Easier maintenance when projection years change
  • Reduced code duplication
  • More robust than hardcoding future values in YAML files

Current Implementation

A working implementation can be found in this PR: https://github.com/PolicyEngine/policyengine-us/pull/6384

The implementation includes:

  • A generic extend_parameter_values function
  • Support for different period types
  • Calculation of growth rates from existing data

Related Discussion

This came up during the review of extending US uprating factors through 2100 for long-term policy simulations.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the policyengine_core.parameters entry point and review the working implementation in policyengine-us PR 6384. Trace how parameter values and period types are represented, then define completion as a reusable extend_parameter_values utility that calculates growth from the last N projected years and extends values to the requested end year.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.