| lag_lead_matrix | R Documentation |
Creates a matrix whose columns are lagged or lead copies of the columns of
x, for integer offsets from_lag through to_lag. A
positive offset k produces a lag (rows k+1 to T of the
output receive rows 1 to T-k of x); a negative offset
k produces a lead. Unfilled positions are set to NA.
lag_lead_matrix(x, from_lag, to_lag)
x |
A numeric matrix with |
from_lag |
Integer. The smallest offset to include (may be negative for leads). |
to_lag |
Integer. The largest offset to include (must be |
Faithful translation of lagleadmatrix.m from the replication package
of Tugan (2021).
A matrix with T rows and K \times (to\_lag - from\_lag +
1) columns. Column block j (1-indexed) corresponds to offset
from\_lag + j - 1.
Tugan, M. (2021). Panel VAR models with interactive fixed effects. Econometrics Journal, 24, 225–246. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/ectj/utaa021")}
x <- matrix(1:12, nrow = 4)
lag_lead_matrix(x, 1, 2) # two lags
lag_lead_matrix(x, -1, 1) # one lead, contemporaneous, one lag
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.