TIME SERIES ANALYSIS

Question 1: Temperature Analysis (30 Points)

In this problem, we will analyze aggregated temperature data.

Data file LA Temp Monthly.csv contains the monthly average temperature of Los Angeles from January 1950 through December 2018. Run the following code to prepare the data for analysis:

#Note ‘TSA’ is now depreciated, use the following to load the parent library

install. packages(locfit)

library(locfit)

library(mgcv)

#Choose the ‘LA Temp Monthly.csv’ dataset, wherever it is located on your computer

#Additionally, just skip this step and replace ‘fname’ with the file’s direct location

fname <- file. choose ()

#Load Data

data <- read.csv(fname)

data <- data [,2]

#Convert to TS data in proper frame

temp <- ts (data, start=c (1950,1), freq=12)

Question 1a: Exploratory Data Analysis 

  • Plot the Time Series and ACF plots. Comment on the main features, and identify what (if any) assumptions of stationarity are violated. Hint: Before plotting, can you infer anything from the nature of the data?
  • On its own, which type of model do you think will fit the data best: trend or seasonality fitting?

Question 1b: Trend Estimation

Fit the following trend estimation models:

  • Moving average
  • Parametric quadratic polynomial
  • Local Polynomial
  • Splines

Overlay the fitted values on the original time series.  Construct and plot the residuals with respect to time and ACF of residuals. Comment on the four models fit and on the appropriateness of the stationarity assumption of the residuals.

Question 1c: Seasonality Estimation

Seasonality Estimation:

Fit the following seasonality estimation models.

  • Categorical Linear Regression (ANOVA)
  • COS-SIN

Overlay the fitted values on the original time series.  Construct and plot the residuals with respect to time and ACF plots. Comment on how the two models fit and on the appropriateness of the stationarity assumption of the residuals. Also compare the fits to those in part B and comment if your initial prediction was correct.

Question 2: Currency Conversion Analysis (40 Points)

In this problem, we will study fluctuations in currency exchange rate over time.

File USD-EUR Exchange.csv contains the average exchange rate of USD/EUR from January 2000 through June 2019, aggregated weekly (ending Wednesdays). Load and prep the data for analysis with the following code:

library(locfit)

library(mgcv)

#Choose the ‘USD-EUR Exchange.csv’ dataset, wherever it is located on your computer

fname <- file. choose ()

#Load data

data <- read.csv(fname)

data <- data [,2]

#Convert to TS data in proper frame

rate <- ts (data, start=c (2000,1), freq=52)

#Generate differenced data

rate.dif <- diff(rate)

Question 2a: Exploratory Data Analysis 

  • Plot the Time Series and ACF plots. Comment on the main features, and identify what (if any) assumptions of stationarity are violated.
  • Using the differenced rate data (‘rate.dif’), plot both the Time Series and ACF plots. Comment on the main features, and identify what (if any) assumptions of stationarity are violated. Additionally, comment if you believe the differenced data is more appropriate for use in analysis. Support your position with your graphical analysis.

Question 2b: Trend-Seasonality Estimation

Using the original time series data, fit the following models to estimate both trend and seasonality:

  • Parametric Polynomial Regression
  • Non-parametric model

Overlay the fitted values on the original time series. Construct and plot the residuals with respect to time and ACF of residuals. Comment on how the two models fit and on the appropriateness of the stationarity assumption of the residuals. For sake of simplicity, only use Categorical Regression (ANOVA) seasonality modelling.

Question 2c: Trend-Seasonality Estimation with Differenced Data

Now using the differenced time series data, construct the same type of models as you did above. Overlay the fitted values on the original time series. Construct and plot the residuals with respect to time and ACF of residuals. Comment on the two models fit and on the appropriateness of the stationarity assumption of the residuals. Additionally, comment if models built with original or differenced data appear to differ in quality of fit; which (if any) is better?

Hint:

When TS data is differenced, the resulting dataset begins observations at the second time point of the original series. To ensure fitted values line up properly, convert them to time series with the following function:

ts (fit, start=c (2000,2), freq=52)

Where “fit” represents the appropriate fitted values. This function communicates that the time series is broken down into 52 equal sized chunks (weeks) each year (freq=52), and that this particular series begins with the second chunk of the year 2000 (start=c (2000,2)).

Assignment
1.Plot all the series (an advanced data visualization tool is recommended) – what type of components are visible? Are the series similar or different? Check for problems such as missing values and possible errors.
2. Partition the series into training and validation, so that the last 4 years are in the validation period for each series. What is the logic of such a partitioning? What is the disadvantage?
3. Generate naive forecasts for all series for the validation period. For each series, create forecasts with horizons of 1,2,3, and 4 years ahead (Ft+1, Ft+2, Ft+3, and Ft+4).
4. Among the measures MAE, Average error, MAPE and RMSE, which are suitable if we plan to combine the results for the 518 series?
5. For each series, compute MAPE of the naive forecasts once for the training period and once for the validation period.
6. The performance measure used in the competition is Mean Absolute Scaled Error (MASE). Explain the advantage of MASE and compute the training and validation MASE for the naive forecasts.
7. Create a scatterplot of the MAPE pairs, with the training MAPE on the x-axis and the validation MAPE on the y-axis. Create a similar scatter plot for validation MASE vs. MAPE. Now examine both plots. What do we learn? How does performance differ between the training and validation periods? How does performance range across series?
8. The competition winner, Lee Baker, used an ensemble of three methods:
• Naive forecasts multiplied by a constant trend (global/local trend: “globally tourism has grown “at a rate of 6% annually.”)
• Linear regression
• Exponentially-weighted linear regression
(a) Write the exact formula used for generating the first method, in the form Ft+k=…(k=1,2,3,4).
(b) What is the rational behind multiplying the naive forecasts by a constant? (Hint: think empirical and domain knowledge)
(c) What should be the dependent variable and the predictors in a linear regression model for these data? Explain.
(d) Fit the linear regression model to the first five series and compute forecast errors for the validation period.
(e) Before choosing a linear regression, the winner described the following process
“I examined fitting a polynomial line to the data and using the line to predict future values. I tried using first through fifth order polynomials to find that the lowest MASE was obtained using a first order polynomial (simple regression line). This best fit line was used to predict future values. I also kept the [R2] value of the fit for use in blending the results of the predictor.”
What are two flaws in this approach?
(f) If we were to consider exponential smoothing, what particular type(s) of exponential smoothing are reasonable candidates?
(g) The winner concludes with possible improvements, one being “an investigation into how to come up with a blending [ensemble] method that doesn’t use as much manual tweaking would also be of benefit.” Can you suggest methods or an approach that would lead to easier automation of the ensemble step?

(h) The competition focused on minimizing the average MAPE of the next four values across all 518 series. How does this goal differ from goals encountered in practice when considering tourism demand? Which steps in the forecasting process would likely be different in a real-life tourism forecasting scenario?

Case Study Assignment #2 is based on the second case presented in Chapter 11 of the Practical Time Series Forecasting textbook (pages 215-218). This case is to practice forecasting multiple time series, all related to tourism demand. Read the information on those pages of the textbook. The data can be found in tourism_data.csv. You may also want to view the article Athanasopoulos et al. - 2011 - The tourism forecasting competition.pdf

Your assignment is to address the questions on pages 216-218. Use whatever software resources make the most sense (Tableau, Excel, R, etc.) given that you are working with more than 500 time series. (Remember that for the regression model in 8(d) you are only to forecast the first 5 series). Your response to the case will be answers to the text questions (upload Excel or Tableau files, along with a Word file or .pdf with responses to the written questions). Document any sources used.