Session Ready
Exercise

Manipulating MA unemployment data

Now that you've added some lags, differences, and rolling values to your GDP and US unemployment data, it's time to take these skills back to your assignment.

Remember that your client wants information relevant to the Boston tourism industry. In addition to data on the US economy in general, it may help to prepare some relevant indicators for your Massachusetts economic data.

In this exercise, you'll use your time series data manipulation skills to generate: a one-year lag, a six-month first order difference, a six-month rolling average, and a one-year rolling maximum in the MA unemployment rate. Your client is waiting!

Instructions
100 XP
  • Use lag() to generate a one-year lag of the MA unemployment rate (contained in the ma column of your monthly unemployment data). Remember to set the k argument equal to a year's worth of observations. Save this indicator to your unemployment data as ma_yearlag.
  • Use diff() to generate a six-month first order difference in the MA unemployment rate. Remember to specify the correct column in your unemployment data. Save this indicator to your unemployment data as ma_sixmonthdiff.
  • Measure the six-month rolling average of MA unemployment using rollapply() Be sure to provide the appropriate specification for the width and FUN arguments. Save this indicator to your unemployment data as ma_sixmonthavg.
  • Measure the "high water mark" in unemployment over the past year using another call to rollapply() with the appropriate specification of the width argument. This time, set the FUN argument to max. Save this final indicator to your unemployment data as ma_yearmax.
  • Use tail() to view the last year of unemployment data (n = 12).