RainbowStats Command Reference
Spectral Analysis Functions
These commands examine relationships between time series in the frequency domain. Rather than measuring only a single overall correlation, spectral analysis identifies the cycle lengths at which two or more series move together.
Spectral Transfer Function using Welch's Method
Overview
SPECTRAL_TRANSFER_FUNCTION_WELCH estimates the frequency-domain relationship between two time series using Welch's averaged periodogram method. It can reveal which repeating cycles are shared, how strongly the series are related at each cycle length, and whether one series tends to lead or lag the other.
Welch's method divides the data into overlapping segments, estimates the spectrum for each segment, and averages the results. This reduces noise and generally produces a more stable estimate than a single-periodogram calculation.
Syntax
result = SPECTRAL_TRANSFER_FUNCTION_WELCH(series1, series2)
extract(result, 0)
Parameters
| Parameter | Description |
|---|---|
series1 |
The input or explanatory time series. |
series2 |
The output or response time series. |
The two series should normally use the same observation frequency and cover a compatible date range.
Example
str = SPECTRAL_TRANSFER_FUNCTION_WELCH(logdiff(U6Rate), logdiff(TCU))
extract(str, 0)
This example examines how changes in the U-6 unemployment rate are related to changes in industrial capacity utilization across different business-cycle frequencies.
What the Analysis Can Show
- Coherence: the strength of the relationship at each frequency.
- Gain: the size of the response in one series relative to the other.
- Phase: the lead-lag relationship between the two series.
- Dominant periods: the cycle lengths where the relationship is strongest.
- Power spectra: the frequencies containing the greatest variation in each series.
Typical Uses
- Business-cycle analysis
- Leading-indicator research
- Financial-market relationships
- Economic and industrial systems
- Signal and time-series analysis
Spectral Transfer Matrix
Overview
SPECTRAL_TRANSFER_MATRIX performs pairwise spectral analysis across a list of time series and presents the selected result as a matrix. It is designed for rapid exploratory analysis when the user wants to compare several variables without running each pair separately.
Syntax
SPECTRAL_TRANSFER_MATRIX(seriesList, statistic)
Parameters
| Parameter | Description |
|---|---|
seriesList |
A list containing two or more time series. |
statistic |
The spectral result to display for every pair of series. |
Supported Statistics
| Statistic | Description |
|---|---|
PEAK |
The maximum coherence found between each pair of series. |
AVG |
The average coherence across the analyzed frequencies. |
BEST_PERIOD |
The cycle length at which the strongest relationship occurs. |
Example
l = logDiff(List(DGS10, SP500, VIXCLS, VXNCLS))
spectral_transfer_matrix(l, PEAK)
This example calculates the maximum spectral coherence between the 10-year Treasury yield, the S&P 500, the VIX, and the Nasdaq Volatility Index.
Interpreting the Matrix
- High PEAK: the two series share at least one strong common cycle.
- High AVG: the relationship persists across a broad range of frequencies.
- BEST_PERIOD: identifies the cycle length where the pair is most closely related.
Typical Uses
- Scanning groups of economic indicators
- Comparing financial assets or volatility measures
- Finding candidate leading indicators
- Identifying synchronized business cycles
- Selecting series for more detailed analysis
Recommended Workflow
-
Use
SPECTRAL_TRANSFER_MATRIXto scan a group of series and identify strong or unusual relationships. -
Use
SPECTRAL_TRANSFER_FUNCTION_WELCHon a selected pair for a complete, frequency-by-frequency analysis.