See https://book.declaredesign.org/observational-causal.html#difference-in-differences
lag_by_group(x, groups, n = 1, order_by, default = NA)
vector of lagged values
Vector of values
Grouping variable
Positive integer of length 1, giving the number of positions to lead or lag by
Ordering variable withing group (e.g., time)
Value used for non-existent rows. Defaults to NA.