Econ detrending correlation

From XuShuwenn/RedAct · View interactive version

Econ detrending correlation is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Apply Hodrick-Prescott filter to detrend economic time series and calculate Pearson correlation between consumption and investment.

How to use this skill

Skill file

Economic Time Series Detrending and Correlation

When to Use

Input Files

Key Steps

  1. Inspect each input workbook first: print sheet names, column labels, and a few representative rows before coding against assumed headers or row formats
  2. Extract Personal Consumption Expenditures (Total, column 1) and PFI (Total, column 1) from their ERP tables separately
  3. Build independent year→value mappings for each series, then merge by year; do not assume matching row numbers across the two files
  4. Handle quarterly data at end of tables; for 2024, statefully track the active year, enumerate all matched 2024 quarter rows, and compute the annual 2024 value as the mean of all available 2024 quarters
  5. Validate extraction results before proceeding: ensure annual observations are non-empty, years are in expected order, and 2024 handling did not accidentally pull quarters from earlier years or remove the series
  6. Deflate nominal series using CPI to get real values only after confirming the actual CPI year/value columns in /root/CPI.xlsx
  7. Apply Hodrick-Prescott filter with λ=100 to ln(real series)
  8. Compute Pearson correlation between two cyclical components
  9. Round result to 5 decimal places
  10. Before concluding, explicitly print the extracted 2024 quarter labels/values, the final correlation, and read back /root/answer.txt to confirm the saved value matches the computed value

HP Filter

Validation Checks

Validation Checks

Output Format

Single number to /root/answer.txt

Before trusting /root/answer.txt, verify the computation ran end-to-end: confirm deflation, HP filtering, and correlation steps executed successfully and the script exited normally. If output is truncated or diagnostics stop early, rerun or inspect the error instead of treating an existing answer file as success.

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.