# lag.plm: lag, lead, and diff for panel data In plm: Linear Models for Panel Data

## Description

lag, lead, and diff functions for class pseries.

## Usage

 1 2 3 4 5 6 7 8 9 10 lead(x, k = 1, ...) ## S3 method for class 'pseries' lag(x, k = 1, shift = c("time", "row"), ...) ## S3 method for class 'pseries' lead(x, k = 1, shift = c("time", "row"), ...) ## S3 method for class 'pseries' diff(x, lag = 1, shift = c("time", "row"), ...)

## Arguments

 x a pseries object, k an integer, the number of lags for the lag and lead methods (can also be negative). For the lag method, a positive (negative) k gives lagged (leading) values. For the lead method, a positive (negative) k gives leading (lagged) values, thus, lag(x, k = -1) yields the same as lead(x, k = 1). If k is an integer with length > 1 (k = c(k1, k2, ...)), a matrix with multiple lagged pseries is returned, ... further arguments (currently none evaluated). shift character, either "time" (default) or "row" determining how the shifting in the lag/lead/diff functions is performed (see Details and Examples). lag the number of lags for the diff method, can also be of length > 1 (see argument k) (only nonâ€“negative values in argument lag are allowed for diff),

## Details

This set of functions perform lagging, leading (lagging in the opposite direction), and differencing operations on pseries objects, i. e., they take the panel structure of the data into account by performing the operations per individual.

Argument shift controls the shifting of observations to be used by methods lag, lead, and diff:

#' - shift = "time" (default): Methods respect the numerical value in the time dimension of the index. The time dimension needs to be interpretable as a sequence t, t+1, t+2, ... where t is an integer (from a technical viewpoint, as.numeric(as.character(index(your_pdata.frame)[[2]])) needs to result in a meaningful integer).

• shift = "row": Methods perform the shifting operation based solely on the "physical position" of the observations, i.e., neighbouring rows are shifted per individual. The value in the time index is not relevant in this case.

For consecutive time periods per individual, a switch of shifting behaviour results in no difference. Different return values will occur for non-consecutive time periods per individual ("holes in time"), see also Examples.

## Value

• An object of class pseries, if the argument specifying the lag has length 1 (argument k in functions lag and lead, argument lag in function diff).

• A matrix containing the various series in its columns, if the argument specifying the lag has length > 1.

## Note

The sign of k in lag.pseries results in inverse behaviour compared to stats::lag() and zoo::lag.zoo().

## Author(s)

Yves Croissant and Kevin Tappe