Home | Command Reference | Run Example

Lag Command

The Lag command converts a time series into Lagged time series

Main idea: rather than analyzing the lag of a variable.

Example


lag(sp500,5)

This example transforms the S&P 500 Index into a series with a five day lag

Syntax


lag(series,12)

Mathematical Definition

For a time series X, the lag:


Lag(X,n) = xtn

Common Applications

Example: Retail Sales Growth


lag(RSAFSNA,1)

Instead of examining the level of retail sales, this transformation focuses on monthly growth rates. Seasonal effects, business cycle dynamics, and unusual economic events often become easier to identify after converting the series to growth rates.

Script Example


sales = lag(RSAFSNA,5)
plot(sales)

Related Commands

The lag command is one of the foundational transformations used throughout RainbowStats.