Session Ready
Exercise

First differences

Now that we know how to take lags, generating first-differences is pretty straightforward. The first-difference of a time series just involves taking each value and subtracting the value observed at the previous time period.

dailyDT is available in your session.

Instructions 1/3
undefined XP
  • 1
    • Add a column called sales_lag1 that holds the one-period lag in "sales"
    • 2
      • Add the one-period difference in sales, sales_diff1, using the precomputed lag column.
    • 3
      • Add the two-period difference in sales, sales_diff2, without referencing the precomputed lag column.