Data & analytics
evo-business-cycle
Calculate Pearson correlation between HP-filtered cyclical components of real PCE and real PFI from ERP tables and CPI data. Use when detrending macroeconomic time series and computing business cycle correlations.
Zhang-Henry · AI review on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add Zhang-Henry/CoEvoSkills --skill evo-business-cycleAbout this skill
name: evo-business-cycle description: "Calculate Pearson correlation between HP-filtered cyclical components of real PCE and real PFI from ERP tables and CPI data. Use when detrending macroeconomic time series and computing business cycle correlations."
Business Cycle Correlation Skill
This skill extracts nominal PCE and PFI from ERP Excel tables, deflates them using a CPI index, applies the Hodrick-Prescott filter on log-transformed real series, and computes the Pearson correlation of the cyclical components.
Workflow
- Parse ERP .xls tables to extract annual totals (column 1)
- For years with only quarterly data, average available quarters
- Deflate nominal series using CPI (real = nominal / CPI)
- Take natural logarithm of real series
- Apply HP filter with specified lambda (100 for annual data)
- Compute Pearson correlation of cyclical components
- Write rounded result to output file
Usage Example
import sys
sys.path.insert(0, '/app/environment/skills/evo-business-cycle/scripts')
from utils import run_business_cycle_correlation, validate_result
# Run end-to-end
corr = run_business_cycle_correlation(
pce_filepath='/root/ERP-2025-table10.xls',
pfi_filepath='/root/ERP-2025-table12.xls',
cpi_filepath='/root/CPI.xlsx',
output_filepath='/root/answer.txt',
start_year=1973,
end_year=2024,
hp_lambda=100,
decimals=5
)
# Validate
validate_result('/root/answer.txt')
Key Functions
extract_erp_annual_data(filepath, data_start_row, col_index)- Parse annual rows from ERP tablesextract_erp_quarterly_for_year(filepath, target_year, data_start_row, col_index)- Get quarterly values for a specific yearload_cpi(filepath)- Load CPI data from xlsxdeflate_series(nominal_dict, cpi_dict)- Convert nominal to real valueshp_filter(series_values, lamb)- Apply HP filter, returns (cycle, trend)compute_correlation(series1, series2)- Pearson correlationrun_business_cycle_correlation(...)- End-to-end entry pointvalidate_result(output_filepath)- Validate output file