Lagging and differencing

Case Study: Analyzing City Time Series Data in R

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Lagging

  • lag() offsets observations in time
lag(unemployment, k = 1, ...)

table with lagged data moved down by one cell

Case Study: Analyzing City Time Series Data in R

Differencing

  • diff() measures change between periods
diff(unemployment, lag = 1, ...)

table with differenced data where cell value equals current cell minus previous cell

Case Study: Analyzing City Time Series Data in R

Let's practice!

Case Study: Analyzing City Time Series Data in R

Preparing Video For Download...