Agent skill

Timeseries Detrending

by benchflow-ai in benchflow-ai/skillsbench

Tools and techniques for detrending time series data in macroeconomic analysis.

Apache-2.0Auto-check passedData & Analytics

Install Timeseries Detrending

skills CLI
$ npx skills add benchflow-ai/skillsbench --skill timeseries-detrending -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install benchflow-ai/skillsbench timeseries-detrending --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/benchflow-ai/skillsbench.git skills-src && mkdir -p .claude/skills && cp -r skills-src/tasks/econ-detrending-correlation/environment/skills/timeseries-detrending .claude/skills/timeseries-detrending && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
timeseries-detrending
GitHub stars
1.8k
Token cost
~1.2k tokens
SKILL.md length
365 words
Files
1
Skills in repo
189
Repo updated
First seen
Licence
Apache-2.0

At a glance

Tools and techniques for detrending time series data in macroeconomic analysis.

  • Works in 4 steps: Multiplicative to Additive: Converts… → Stabilizes Variance: Growth rates become… → Economic Interpretation: Cyclical… → …
  • Working with economic time series that need to be decomposed into trend and cyclical components
  • SKILL.md covers Overview, The Hodrick-Prescott (HP) Filter, Log Transformation for Growth… and Complete Workflow for Detrending, plus 1 more section
  • Calls pip

What it does

Timeseries Detrending is an agent skill from benchflow-ai/skillsbench. Tools and techniques for detrending time series data in macroeconomic analysis. Use when working with economic time series that need to be decomposed into trend and cyclical components. Covers HP filter, log transformations for growth series, and correlation analysis of business cycles.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Data & Analytics, covering Forecasting and time series. The repository describes itself as: SkillsBench evaluates how well skills work and how effective agents are at using them. The licence is Apache-2.0.

When your agent uses it

  • Working with economic time series that need to be decomposed into trend and cyclical components
  • Tasks that involve Forecasting and time series

Example prompts

  • “Use the timeseries-detrending skill to tool and techniques for detrending time series data in macroeconomic analysis”
  • “/timeseries-detrending”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Multiplicative to Additive: Converts percentage changes to log differences
  2. Stabilizes Variance: Growth rates become comparable across time
  3. Economic Interpretation: Cyclical component represents percentage deviations from trend
  4. Standard Practice: Required for business cycle statistics that compare volatilities

What it can do on your machine

Read from SKILL.md and the folder at commit 9a1f4dd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Timeseries Detrending loads about 1.2k tokens when it runs. Until then it costs about 77 tokens; SKILL.md has 365 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from benchflow-ai/skillsbench at commit 9a1f4dd, republished under its Apache-2.0 licence (© benchflow-ai). 365 words, ~1,163 tokens.

Download SKILL.mdSave it as .claude/skills/timeseries-detrending/SKILL.md (or your agent's skills folder).
name
timeseries-detrending
description
Tools and techniques for detrending time series data in macroeconomic analysis. Use when working with economic time series that need to be decomposed into trend and cyclical components. Covers HP filter, log transformations for growth series, and correlation analysis of business cycles.

Time Series Detrending for Macroeconomic Analysis

This skill provides guidance on decomposing economic time series into trend and cyclical components, a fundamental technique in business cycle analysis.

Overview

Economic time series like GDP, consumption, and investment contain both long-term trends and short-term fluctuations (business cycles). Separating these components is essential for:

  • Analyzing business cycle correlations
  • Comparing volatility across variables
  • Identifying leading/lagging indicators

The Hodrick-Prescott (HP) Filter

The HP filter is the most widely used method for detrending macroeconomic data. It decomposes a time series into a trend component and a cyclical component.

Mathematical Foundation

Given a time series $y_t$, the HP filter finds the trend $\tau_t$ that minimizes:

$$\sum_{t=1}^{T}(y_t - \tau_t)^2 + \lambda \sum_{t=2}^{T-1}[(\tau_{t+1} - \tau_t) - (\tau_t - \tau_{t-1})]^2$$

Where:

  • First term: Minimizes deviation of data from trend
  • Second term: Penalizes changes in the trend's growth rate
  • $\lambda$: Smoothing parameter controlling the trade-off
Choosing Lambda (λ)

Critical: The choice of λ depends on data frequency:

Data FrequencyRecommended λRationale
Annual100Standard for yearly data
Quarterly1600Hodrick-Prescott (1997) recommendation
Monthly14400Ravn-Uhlig (2002) adjustment

Common mistake: Using λ=1600 (quarterly default) for annual data produces an overly smooth trend that misses important cyclical dynamics.

Python Implementation
python
from statsmodels.tsa.filters.hp_filter import hpfilter
import numpy as np

# Apply HP filter
# Returns: (cyclical_component, trend_component)
cycle, trend = hpfilter(data, lamb=100)  # For annual data

# For quarterly data
cycle_q, trend_q = hpfilter(quarterly_data, lamb=1600)

Important: The function parameter is lamb (not lambda, which is a Python keyword).

Log Transformation for Growth Series

Show full SKILL.md (154 more words)Show less
Why Use Logs?

For most macroeconomic aggregates (GDP, consumption, investment), you should apply the natural logarithm before filtering:

  1. Multiplicative to Additive: Converts percentage changes to log differences
  2. Stabilizes Variance: Growth rates become comparable across time
  3. Economic Interpretation: Cyclical component represents percentage deviations from trend
  4. Standard Practice: Required for business cycle statistics that compare volatilities
python
import numpy as np

# Apply log transformation BEFORE HP filtering
log_series = np.log(real_series)
cycle, trend = hpfilter(log_series, lamb=100)

# The cycle now represents percentage deviations from trend
# e.g., cycle = 0.02 means 2% above trend
When NOT to Use Logs
  • Series that can be negative (net exports, current account)
  • Series already expressed as rates or percentages
  • Series with zeros

Complete Workflow for Detrending

Step-by-Step Process
  1. Load and clean data: Handle missing values, ensure proper time ordering
  2. Convert to real terms: Deflate nominal values using appropriate price index
  3. Apply log transformation: For positive level variables
  4. Apply HP filter: Use appropriate λ for data frequency
  5. Analyze cyclical component: Compute correlations, volatilities, etc.
Example: Business Cycle Correlation
python
import pandas as pd
import numpy as np
from statsmodels.tsa.filters.hp_filter import hpfilter

# Load real (inflation-adjusted) data
real_consumption = pd.Series(...)  # Real consumption expenditure
real_investment = pd.Series(...)   # Real fixed investment

# Log transformation
ln_consumption = np.log(real_consumption)
ln_investment = np.log(real_investment)

# HP filter with λ=100 for annual data
cycle_c, trend_c = hpfilter(ln_consumption, lamb=100)
cycle_i, trend_i = hpfilter(ln_investment, lamb=100)

# Compute correlation of cyclical components
correlation = np.corrcoef(cycle_c, cycle_i)[0, 1]
print(f"Business cycle correlation: {correlation:.4f}")

Dependencies

Ensure these packages are installed:

bash
pip install statsmodels pandas numpy

The HP filter is in statsmodels.tsa.filters.hp_filter.

© benchflow-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in tasks/econ-detrending-correlation/environment/skills/timeseries-detrending of benchflow-ai/skillsbench.

Open the folder on GitHubat commit 9a1f4dd

Compare with similar skills

Timeseries Detrending next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Timeseries Detrending compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Timeseries Detrending this skillbenchflow-ai/skillsbench1.8k—~1.2kAutomated safety check: PassApache-2.0
TimesFM Forecastinggoogle-research/timesfm34k—~4.7kAutomated safety check: PassApache-2.0
StatsmodelszLanqing/codex-claude-academic-skills4.7k15 repos~4.9kAutomated safety check: PassBSD-3-Clause
Timesfm ForecastingzLanqing/codex-claude-academic-skills4.7k3 repos~7.5kAutomated safety check: NotesApache-2.0
Find Hypertable Candidatestimescale/pg-aiguide1.9k1 repos~2.6kAutomated safety check: PassApache-2.0
Pensieve Searcharkohut/pensieve1.4k—~8.2kAutomated safety check: PassApache-2.0

Similar skills

  • TimesFM Forecasting

    google-research/timesfm

    Forecasts any univariate time series zero-shot with Google's TimesFM model, returning point forecasts and calibrated prediction intervals without training.

    34k GitHub stars~4.7k tokensUpdated 11 days ago
    Data & AnalyticsAuto-check passed
  • Statsmodels

    zLanqing/codex-claude-academic-skills

    Statistical models library for Python. An agent skill from zLanqing/codex-claude-academic-skills.

    4.7k GitHub starsUsed in 15 repos~4.9k tokens
    Data & AnalyticsAuto-check passed
  • Timesfm Forecasting

    zLanqing/codex-claude-academic-skills

    Zero-shot time series forecasting with Google's TimesFM foundation model.

    4.7k GitHub starsUsed in 3 repos~7.5k tokens
    Data & AnalyticsAuto-check: notes
  • Find Hypertable Candidates

    timescale/pg-aiguide

    A skill your agent uses to analyze an existing PostgreSQL database and identify which tables should be converted to Timescale/TimescaleDB hypertables.

    1.9k GitHub starsUsed in 1 repo~2.6k tokens
    Data & AnalyticsAuto-check passed
  • Pensieve Search

    arkohut/pensieve

    Search the user's local Pensieve screenshot archive by text, app, or time range.

    1.4k GitHub stars~8.2k tokensUpdated 2 mo ago
    Data & AnalyticsAuto-check passed
  • Alphaear Predictor

    ninehills/skills

    Market prediction skill using Kronos. An agent skill from ninehills/skills.

    280 GitHub starsUsed in 1 repo~531 tokens
    Data & AnalyticsAuto-check passed

More from benchflow-ai/skillsbench

All 189 skills in this repo
  • Lean4 Memories

    benchflow-ai/skillsbench

    This skill should be used when working on Lean 4 formalization projects to maintain persistent memory of successful proof patterns, failed approaches, project conventions, and user preferences…

    1.8k GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Senior Data Engineer

    benchflow-ai/skillsbench

    World-class data engineering skill for building scalable data pipelines, ETL/ELT systems, real-time streaming, and data infrastructure.

    1.8k GitHub stars~5.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Ac Branch Pi Model

    benchflow-ai/skillsbench

    AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching acopf-math-model.md and MATPOWER branch fields.

    1.8k GitHub stars~1.1k tokensUpdated 2 mo ago
    Auto-check passed
  • Civ6lib

    benchflow-ai/skillsbench

    Civilization 6 district mechanics library. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~1.7k tokensUpdated 2 mo ago
    Auto-check passed
  • D3 Visualization

    benchflow-ai/skillsbench

    Build deterministic, verifiable data visualizations with D3.js (v6).

    1.8k GitHub stars~1.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Dc Power Flow

    benchflow-ai/skillsbench

    DC power flow analysis for power systems. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~717 tokensUpdated 2 mo ago
    Auto-check passed

Questions about Timeseries Detrending

What does Timeseries Detrending do?

Tools and techniques for detrending time series data in macroeconomic analysis. Timeseries Detrending is an agent skill from benchflow-ai/skillsbench. Tools and techniques for detrending time series data in macroeconomic analysis.

When should I use Timeseries Detrending?

Timeseries Detrending fits situations like: working with economic time series that need to be decomposed into trend and cyclical components; tasks that involve Forecasting and time series.

How do I install Timeseries Detrending in Claude Code?

Run `npx skills add benchflow-ai/skillsbench --skill timeseries-detrending -a claude-code`. Or copy the skill folder (tasks/econ-detrending-correlation/environment/skills/timeseries-detrending in benchflow-ai/skillsbench) into .claude/skills/timeseries-detrending in your project. Claude Code loads it when a task matches its description.

How do I install Timeseries Detrending in Codex?

Run `npx skills add benchflow-ai/skillsbench --skill timeseries-detrending -a codex`. Or copy the skill folder (tasks/econ-detrending-correlation/environment/skills/timeseries-detrending in benchflow-ai/skillsbench) into .agents/skills/timeseries-detrending in your project. Codex loads it when a task matches its description.

Can I use Timeseries Detrending in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add benchflow-ai/skillsbench --skill timeseries-detrending -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/timeseries-detrending, .gemini/skills/timeseries-detrending, .github/skills/timeseries-detrending and .opencode/skills/timeseries-detrending in your project.

What does Timeseries Detrending need to run?

Going by SKILL.md and its folder, Timeseries Detrending needs the command-line tools its instructions call (pip). Our summary lists: Python 3.

Does Timeseries Detrending access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Timeseries Detrending safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Timeseries Detrending use?

Timeseries Detrending is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Timeseries Detrending use?

About 1.2k tokens (SKILL.md is roughly 4.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Timeseries Detrending?

Skills that share tags, products or a category with Timeseries Detrending: TimesFM Forecasting (google-research/timesfm, 34k stars), Statsmodels (zLanqing/codex-claude-academic-skills, 4.7k stars), Timesfm Forecasting (zLanqing/codex-claude-academic-skills, 4.7k stars) and Find Hypertable Candidates (timescale/pg-aiguide, 1.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Timeseries Detrending?

benchflow-ai (a GitHub organization) maintains it in benchflow-ai/skillsbench, which has 1,835 GitHub stars. The repository holds 189 skills in this directory. The repository was last updated on July 23, 2026.

Source: benchflow-ai/skillsbench on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.