PolicyEngine US

1.636.3 · active · verified Thu Apr 16

PolicyEngine US is an open-source Python library that provides a comprehensive microsimulation model of the United States tax and benefit system. Built upon the PolicyEngine Core framework (a fork of OpenFisca), it accurately models federal individual income taxes, major federal benefit programs, and state income taxes for all 50 states and D.C. The library enables researchers and policymakers to estimate household-level tax liabilities and benefit eligibility, and to simulate the distributional impacts and budgetary effects of proposed policy reforms. It is actively maintained with continuous updates driven by changes in tax and benefit legislation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple household, retrieve the current US tax-benefit system, run a simulation to calculate a person's net income, and then apply a basic policy reform (Universal Basic Income) to see its impact.

from policyengine_us import system
from policyengine_core.entities import Person, Household
from policyengine_core.simulation import Simulation

# Define a simple household
# A person named 'alice' who is 40 years old and has wage income
alice = Person(age=40, wages=50000, employment_status='EMPLOYED')

# A household with Alice
household = Household(members=[alice])

# Get the current US tax-benefit system
# By default, uses the latest available policy year (e.g., 2025 as of recent updates)
sim_system = system.get_system()

# Create a simulation for the household
simulation = Simulation(household=household, system=sim_system)

# Calculate a variable, e.g., Alice's net income in 2025
alice_net_income = simulation.get_person_variable(person_id=alice.id, variable_name='net_income', period='2025')

print(f"Alice's net income in 2025: ${alice_net_income:,.2f}")

# Example of applying a simple reform (e.g., a universal basic income)
reform_code = {
    'universal_basic_income': [
        {
            'period': '2025',
            'value': 12000,
            'description': 'A universal basic income of $12,000 per year for all adults.'
        }
    ]
}

# Apply the reform to the system
reformed_system = system.get_system(reform=reform_code)

# Run simulation with the reformed system
reformed_simulation = Simulation(household=household, system=reformed_system)

alice_net_income_reformed = reformed_simulation.get_person_variable(
    person_id=alice.id, variable_name='net_income', period='2025'
)

print(f"Alice's net income in 2025 with UBI reform: ${alice_net_income_reformed:,.2f}")

view raw JSON →