Rolling PCA Pass Node

Rolling PCA — First Principal Component

StatisticalDimensionality ReductionPass

Overview

The Rolling PCA Pass Node applies Principal Component Analysis to a rolling window of a single series, projecting it onto its first principal component. The result captures the dominant linear variation structure within the window.

In the single-series case, the first PC is equivalent to a normalised projection capturing the cumulative variance pattern. This is most powerful when extended to multi-series inputs for factor extraction and dimensionality reduction.

Formula

Per rolling window:
X = standardise(window)   [subtract mean, divide by std]
C = X^T × X / (n−1)   [covariance matrix]
pc1 = first eigenvector of C (largest eigenvalue)
score[i] = X[−1] · pc1   [projection of latest observation]
Warm-up: period bars.

Parameters

ParameterDefaultDescription
period30Rolling window in bars

Inputs & Outputs

SlotDirectionTypeDescription
inputInput{ values, timestamps }Any upstream numeric series
valuesOutput(number | null)[]First PC score per bar; nulls during warm-up
timestampsOutputnumber[]Unix timestamps aligned to input

Use Cases

Dominant Trend Extraction

The first PC captures the dominant direction of variation in the window — useful as a smooth, orthogonal trend signal.

Regime Detection

Monitor changes in PC1 loadings over time to detect shifts in the structure of price dynamics — leading indicator of regime change.

Noise Reduction

Project a noisy series onto its first PC to extract the signal component, filtering out random noise within the rolling window.

Tips & Best Practices

Sign Flip Awareness

PC1 eigenvectors can flip sign between windows. This causes sign ambiguity in the output — apply careful sign correction or use absolute values if the direction doesn't matter.

Use Larger Windows

PCA is noisy with small samples. Use period ≥ 30 for meaningful results. Period = 60 or more is preferred for stable eigenvectors.

Combine with Hurst or DFA

Use PCA output alongside Hurst Exponent or DFA to confirm whether the extracted component is trending or mean-reverting.

Related Indicators