A function that calculates the first difference in a panel data setting. If the data.frame that is passed in has nxT rows, the resulting vector will also have nxT elements with one element for each unit set to be NA.
Value
a vector with one element per row of df: the change in yname
from the unit's previous period (ordered by tname), NA for each
unit's first period
Examples
n <- 50
id <- rep(seq_len(n), each = 4)
t <- rep(1:4, n)
y <- rnorm(n * 4)
dta <- data.frame(id = id, t = t, y = y)
dy <- get_first_difference(dta, idname = "id", yname = "y", tname = "t")
