Lagged predictors, transfer functions, and forecasting the predictor first
Today let's understand what to do when a predictor's effect on your outcome does not land all at once, but keeps showing up for several periods afterward.
Here's the running example. BJsales is a real sales series, 150 consecutive periods, alongside BJsales.lead, a leading indicator recorded at those same 150 periods. Both come from Box and Jenkins' 1976 time series text and ship inside base R. Over the 150 periods, sales ranged from 198.6 to 263.3, averaging 230.0.
Here's the whole sales series, one point for each period.
It isn't a straight climb. Sales start near 200, climb into the low 220s within the first thirty periods, dip back down near 210 around the midpoint, then climb again through the second half to finish near 263.
The leading indicator, and how closely it already tracks sales
A leading indicator is a series recorded alongside your target whose past values may carry information about the target's future. BJsales.lead is exactly that: it is recorded at the same 150 periods as sales, ranging from 9.75 to 13.87 and averaging 11.85.
Plot sales against the leading indicator recorded at the very same period, and the relationship is already easy to see.
The points climb from lower left to upper right, and the correlation shown above the chart, r = 0.951, says the same thing in one number: periods where the indicator sat higher are periods where sales sat higher too, at that very same period. That is already a strong relationship. But a same-period correlation is not the whole story, and that is worth checking directly, next.