Lag

Lag

Lag

Description

Lag, also called the sliding window method, is a backshift operator function. The window width is the number of places the data points are shifted.

Why to use

Lag is used to create a new list of data points by shifting them by an integral number of places.

When to use

To create a shifted list of variables

When not to use

When the data does not contain trend or seasonal factor

Prerequisites

The dataset should contain at least one data point. 

Input

Any time-series data

Output

Dataset with values moved to successive positions

Statistical Methods Used

Limitations



In Lag, no aggregation is performed on the data. The data points are shifted by an integral number of places.
The lag function is also called the sliding window method. The window width indicates the number of places the data points are shifted.
For example, a width of one (1) indicates that in the Lagged column,

  • the first entry is NA
  • subsequent entries are the same as the original column with a shift of one place. Hence in the Lagged data column, the subsequent rows are filled with the values from the previous row in the original column.