policyengine-period-patterns

Convert variable values between YEAR and MONTH definition periods in PolicyEngine US.

31|6|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/PolicyEngine/policyengine-claude --skill policyengine-period-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: policyengine-period-patterns
Source: https://github.com/PolicyEngine/policyengine-claude/tree/main/skills/technical-patterns/policyengine-period-patterns-skill
Command: npx skills add https://github.com/PolicyEngine/policyengine-claude --skill policyengine-period-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill bundles essential patterns for handling different definition periods (YEAR, MONTH) in PolicyEngine and how to convert between them.

Core Features & Use Cases

  • Period access rules: Access YEAR variables from MONTH formulas using period.this_year.
  • Stock vs. flow handling: Correctly handle assets and counts with proper periods.
  • Use Case: Implement monthly eligibility checks that depend on annual demographics.

Quick Start

Use period.this_year to read YEAR variables in a MONTH formula, and convert monthly values back to YEAR when needed.

Frequently Asked Questions about policyengine-period-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I access annual variables from monthly formulas in PolicyEngine?

Use period.this_year to read YEAR-definition variables within MONTH formulas. This Golden Rule pattern ensures correct period-specific access without manual conversion, enabling monthly eligibility checks that depend on annual demographics, assets, or income data.

What's the difference between stock and flow variables when converting between YEAR and MONTH periods?

Stock variables (assets, counts, booleans) use period.this_year for YEAR access; flow variables (income-like metrics) use period directly. Proper handling prevents misalignment when monthly formulas reference annual definitions or vice versa across demographics and financial metrics.

How do I convert monthly values back to annual periods in PolicyEngine?

Apply explicit period conversion patterns documented in this Skill to align monthly-calculated values to YEAR definitions. The conversion handles demographics, assets, counts, and income-flow metrics, ensuring consistent period-specific variable access in both directions.

Can I use monthly eligibility checks with annual demographic variables?

Yes. Period conversion patterns enable MONTH formulas to read annual demographics using period.this_year, supporting monthly eligibility determination that depends on annual-definition data without manual aggregation or period misalignment.

Why do age, assets, counts, and booleans require different period rules than income variables?

Age, assets, counts, and booleans are stock-type variables using period.this_year for consistency within a year; income-like variables are flow-type using period directly. This distinction prevents double-counting and ensures semantically correct period-specific calculations across PolicyEngine formulas.

What happens if I don't explicitly handle period conversion between YEAR and MONTH definitions?

Without explicit conversion, variable values misalign across periods, causing incorrect eligibility outcomes and metric calculations. This Skill documents common MONTH-to-YEAR and YEAR-to-MONTH access patterns and auto-conversion guidance to prevent these issues in demographic, asset, and income-flow contexts.