The standard ARIMA (autoregressive integrated moving average) model allows to make forecasts based only on the past values of the forecast variable. The model assumes that future values of a variable linearly depend on its past values, as well as on the values of past (stochastic) shocks. The ARIMAX model is an extended version of […]

## Forecasting: ARIMAX Model Exercises (Part-5) Solutions

Below are the solutions to these exercises on forecasting with the extended ARIMA model. #################### # # # Exercise 1 # # # #################### require(ggplot2) require(gridExtra) df <- read.csv("Icecream.csv") p1 <- ggplot(df, aes(x = X, y = cons)) + ylab("Consumption") + xlab("") + geom_line() + expand_limits(x = 0, y = 0) p2 <- ggplot(df, aes(x […]

## Forecasting: Multivariate Regression Exercises (Part-4) Solutions

Below are the solutions to these exercises on forecasting with multivariate regression. #################### # # # Exercise 1 # # # #################### auto <- read.csv("vehicles.csv") plot(auto$sales, type = "n", ylim = c(0, 5000), ylab = "Sales, ‘000 units", xlab = "Period", main = "US light vehicle sales in 1976-2016") lines(auto$sales) #################### # # # Exercise […]

## Forecasting: Multivariate Regression Exercises (Part-4)

In the previous exercises of this series, forecasts were based only on an analysis of the forecast variable. Another approach to forecasting is to use external variables, which serve as predictors. This set of exercises focuses on forecasting with the standard multivariate linear regression. Running regressions may appear straightforward but this method of forecasting is […]

## Forecasting: Exponential Smoothing Exercises (Part-3) Solutions

Below are the solutions to these exercises on forecasting with exponential smoothing. #################### # # # Exercise 1 # # # #################### df <- read.csv("unemployment.csv") unempl <- ts(df, start = c(2012, 1), frequency = 12) plot(unempl) #################### # # # Exercise 2 # # # #################### require(forecast) fcast_ses <- ses(unempl, h = 12) plot(fcast_ses) #################### […]

## Forecasting: Exponential Smoothing Exercises (Part-3)

Exponential smoothing is a method of finding patterns in time series, which can be used to make forecasts. In its simple form, exponential smoothing is a weighted moving average: each smoothed value is a weighted average of all past time series values (with weights decreasing exponentially from the most recent to the oldest values). In […]

## Forecasting: Linear Trend and ARIMA Models Exercises (Part-2) Solutions

Below are the solutions to these exercises on forecasting using linear models. #################### # # # Exercise 1 # # # #################### df <- read.csv("ecommerce.csv") series <- ts(df, frequency = 4, start = c(1999, 4)) plot(series) #################### # # # Exercise 2 # # # #################### require(forecast) fcast_naive <- naive(series, h = 8) #################### # […]

## Forecasting: Linear Trend and ARIMA Models Exercises (Part-2)

There are two main approaches to time series forecasting. One of them is to find persistent patterns in a time series itself, and extrapolate those patterns. Another approach is to discover how a series depend on other variables, which serve as predictors. This set of exercises focuses on the first approach, while the second one […]

## Forecasting: Time Series Exploration (Part-1) Solutions

Below are the solutions to these exercises on time series exploration. #################### # # # Exercise 1 # # # #################### df <- read.csv("sales.csv") #################### # # # Exercise 2 # # # #################### series <- ts(df, frequency = 12, start = c(1992,1)) print(series) ## Jan Feb Mar Apr May Jun Jul Aug Sep Oct […]

## Forecasting: Time Series Exploration Exercises (Part-1)

R provides powerful tools for forecasting time series data such as sales volumes, population sizes, and earthquake frequencies. A number of those tools are also simple enough to be used without mastering sophisticated underlying theories. This set of exercises is the first in a series offering a possibility to practice in the use of such […]