ROLL_QUADRATIC

Rolling quadratic turning-point analysis for two time series.

ROLL_QUADRATIC(Y,X,window)

Description

ROLL_QUADRATIC estimates a quadratic relationship between two time series repeatedly through a moving window and calculates the turning point of each fitted quadratic.

For every rolling window, RainbowStats estimates:

Y = β₀ + β₁X + β₂X² + ε

The location of the quadratic turning point is:

X* = −β₁ / (2β₂)

The sign of the quadratic coefficient determines the nature of the turning point:

Condition Interpretation
β₂ < 0 Concave quadratic — X* is a maximum.
β₂ > 0 Convex quadratic — X* is a minimum.
β₂ ≈ 0 The relationship is effectively linear and no stable quadratic turning point is reported.

Syntax

ROLL_QUADRATIC(Y,X,window)
Argument Description
Y The dependent time series.
X The explanatory time series whose turning point is calculated.
window The number of aligned observations included in each rolling quadratic regression.

The two series are automatically restricted to their common date range before estimation.

Returned Chart

The operator returns a D3LineChartOperator showing the estimated turning point through time.

Two series may appear:

Series Meaning
Maximum The value of X* when β₂ is negative.
Minimum The value of X* when β₂ is positive.

Maximum and minimum are therefore not two independently estimated variables. They are the same quadratic vertex classified according to the sign of the fitted curvature.

In-Sample Restriction

RainbowStats reports a turning point only when it lies within the observed range of X in that particular rolling window:

min(Xwindow) ≤ X* ≤ max(Xwindow)

A calculated vertex outside this range is treated as an extrapolation and is not plotted.

Missing portions of the chart are meaningful. A gap may indicate that the fitted quadratic has no economically observable turning point inside the X values present in that window. It does not necessarily indicate missing source data.

Example

The following example examines the relationship between U.S. capital deepening and the wage-and-salary share of gross domestic income.

labor=W270RE1A156NBEA
employment=TO_ANNUAL(PAYEMS)
capital=CAPITAL_STOCK(PNFICA,.06)/employment
capgrowth=logdiff(capital)
ROLL_QUADRATIC(capgrowth,labor,30)

Here:

Interpreting the Example

A full-sample quadratic produces an interior maximum near a wage-and-salary share of 44.14 percent.

capital_labor=same_Date_Range(List(capgrowth,labor)) POLY_SCATTER(capital_labor)

The rolling analysis asks a more demanding question:

Does the location and nature of that turning point remain stable when the quadratic is estimated over different historical windows?

It does not have to.

The estimated turning point may move through time. More importantly, the sign of β₂ may change, causing an estimated maximum to become a minimum or vice versa.

For example, in the U.S. wage-share experiment the rolling relationship changes substantially around the Global Financial Crisis. During the 2009–2011 windows, the fitted curvature reverses and the interior turning point is classified as a minimum rather than a maximum. Subsequent windows again produce maxima.

Interpretation: ROLL_QUADRATIC can reveal not only movement in an estimated optimum or turning point, but changes in the underlying curvature of the relationship itself.

Why Use ROLL_QUADRATIC?

A quadratic fitted to an entire historical sample can produce an apparently precise turning point:

X* = −β₁ / (2β₂)

But that number may conceal substantial instability.

ROLL_QUADRATIC provides a robustness test by asking whether the turning point:

This makes the operator useful for identifying possible structural change and economic regimes without assuming that a full-sample relationship is constant through history.

Choosing a Window

The window determines the tradeoff between local sensitivity and statistical stability.

Window Typical Behavior
Short More responsive to local changes but potentially unstable.
Medium Balances regime sensitivity with estimation stability.
Long Smoother estimates but may obscure shorter structural changes.

For annual macroeconomic data, comparing several windows can be more informative than relying on a single choice.

Related Commands

Command Purpose
POLY_SCATTER(Y,X) Fits and graphs the full-sample polynomial relationship.
ROLL_BETA(Y,X,window) Examines the stability of a linear regression coefficient through time.
BINARY_SPLIT(...) Examines relationships across subsamples.
MVTransfer_Function(...) Models dynamic multivariate relationships and lag structures.

Important Caution

A quadratic turning point is an empirical feature of the fitted relationship. A maximum should not automatically be interpreted as an economic, welfare, investment, or policy optimum. ROLL_QUADRATIC is best used to examine nonlinear relationships and the stability of their turning points through time.