lag

0th

Percentile

lag, lead, and diff for panel data

lag, lead, and diff functions for class pseries.

Keywords
classes
Usage
"lag"(x, k = 1, ...) "lead"(x, k = 1, ...) "diff"(x, lag = 1, ...)
Arguments
x
a pseries object,
k
an integer vector, 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 vector with length > 1 (k = c(k1, k2, ...)) a matrix with multiple lagged pseries is returned,
lag
the number of lags for the diff method (only non--negative values for parameter lag are allowed in diff),
...
further arguments.
Value

These functions return an object of class pseries except if lag (thus also lead) is called with more than one lag (lead), i. e. length(k) > 1, a matrix is returned.

Note

The sign of k in lag.pseries results in inverse behavior compared to lag and lag.zoo.

See Also

For further function for 'pseries' objects: between, Between, Within, summary.pseries, print.summary.pseries, as.matrix.pseries. To check if the time periods are consecutive per individual, see is.pconsecutive.

Aliases
  • lag
  • lead
  • diff
  • lag.pseries
  • lead.pseries
  • diff.pseries
Examples
library(plm) # First, create a pdata.frame data("EmplUK", package = "plm") Em <- pdata.frame(EmplUK) # Then extract a series, which becomes additionally a pseries z <- Em$output class(z) # compute the first and third lag, and the difference lagged twice lag(z) lag(z, 3) diff(z, 2) # compute negative lags (= leading values) lag(z, -1) lead(z, 1) # same as line above identical(lead(z, 1), lag(z, -1)) # TRUE # compute more than one lag at once lag(z, c(1,2))
Documentation reproduced from package plm, version 1.6-5, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.