Abstract
In this workshop we introduce the ARIMAX model, which is an ARIMA/SARIMA model including independent/explanatory variables. The explanatory variables of an ARIMA/SARIMA model are actually one or more AR, MA, Seasonal AR or Seasonal MA terms of the same dependent variable. When we add other explanatory (independent) variables to an ARIMA/SARIMA model, the the model is called an ARIMAX model.You will work in RStudio. Create an R Notebook document (File -> New File -> R Notebook), where you have to write whatever is asked in this workshop.
At the beginning of the R Notebook write Workshop 2 - Financial Econometrics II and your name (as we did in previous workshop).
You have to replicate all the steps explained in this workshop, and ALSO you have to do whatever is asked. Any QUESTION or any STEP you need to do will be written in CAPITAL LETTERS. For ANY QUESTION, you have to RESPOND IN CAPITAL LETTERS right after the question. It is STRONGLY RECOMMENDED that you write your OWN NOTES as if this were your notebook. Your own workshop/notebook will be very helpful for your further study.
You have to keep saving your .Rmd file, and ONLY SUBMIT the .html version of your .Rmd file. Pay attention in class to know how to generate an html file from your .Rmd.
Assume that this industry is an oligopoly where there are few main players in the market that account for most of the market share. In an oligopoly, it is very common that price elasticity of demand is high and sensitive. In other words, when a player decreases the price of a product, it is very likely that its demand will significantly increase. For example, for a price elasticity of -2, if a company decides to reduce the price by 5% in one month, it is expected that on average the demand will increase by about 10% on average.
It is also important to examine not only how the demand of one product changes with respect to its own price, but also how its demand changes with respect to the changes in prices of other products. The concept of cross-elasticity refers to the change of demand of one product with respect to the change in price of another product. If the cross-elasticity coefficient between the demand of product 1 and price of product 2 is about 1.5, this is a sign of competition between both products: when the price of product 2 increases in about 1%, then the demand of product 1 increases in about 1.5%. This price sensitivity might be due to competition between products. If you get a negative cross elasticity coefficient, then this might be a sign of complement between the products.
The concept of price elasticity is simple, but in reality it is not easy to get a good estimate since there are other factors that can influence the demand of a product. For example, it is common that the sales of products in units are seasonal, so the increase in demand might be due to seasonaly more than price elasticity. Another common driver of consumer demand is the organic trend due to either distribution or consumer acceptance. So, we need an econometric model that can separate these drivers and be able to measure price elasticities using a robust method.
Let’s see how we can estimate price elasticities, and how these elasticities along with other main factors that affect demand can help us to do a good demand forecast for products.
For this exercise we will use a sample dataset of main consumer products from main competitors of a category in a country.This dataset has historical sales of the main 7 products of a category, which account for 70% of the share in the category. This dataset was created using real data but changing the name of products. For each product you have sales in value ($) and sales in volume (kgs).
Download the dataset from: http://www.apradie.com/ec2004/salesfabs.xlsx
#I set the working directory:
library(readxl)
library(dplyr)
library(xts)
library(zoo)
library(tseries)
library(forecast)
library(lmtest)
# Download the excel file from a web site:
<- download.file("http://www.apradie.com/ec2004/salesfabs.xlsx",
dataset "dataw6.xlsx", mode="wb")
# The first parameter is the link and the second is a name for the
# local file
# Use the function read_excel()
<- read_excel("dataw6.xlsx") dataset
The columns that start with qfab are related to sales in volume, and vfab refer to sales in value ($). This dataset has historical monthly sales data for 7 consumer products (qfab1, qfab2, etc).
We can create 2 datasets, one for sales in volume and another for sales in value. This will help to easily create another dataset with prices.
<- dataset %>% select(contains("qfab"))
salesvol <- dataset %>% select(contains("vfab")) salesval
Now we can create another dataset for prices. We just divide sales in value by sales in volume to get average historical monthly prices:
# I construct a date variable as a sequence of dates using the month column:
<- seq(as.Date(dataset$month[1]),
date by="month",
length.out = nrow(dataset) )
# I delete the first column since it has the month, and I will construct
# an xts dataset with the index equal to the month
# I create the xts object:
<- xts(x=dataset[,-1], frequency = "monthly", order.by=date)
dataset.xts
<- salesval / salesvol
prices names(prices)<-c("pfab1","pfab2","pfab3","pfab4","pfab5","pfab6","pfab7")
<- ts(coredata(salesvol),start=c(2014,12),frequency=12)
qfabs <- ts(coredata(prices),start=c(2014,12),frequency=12) pfabs
We will calibrate an ARIMAX model for the demand of product 3 (volume sales of product 3) (qfab2). Here is the historical data:
"qfab3"] qfabs[,
## Jan Feb Mar Apr May Jun Jul Aug
## 2014
## 2015 399.9579 474.0180 227.1053 202.1075 239.7118 175.8683 180.6251 190.2039
## 2016 442.6301 478.3997 248.4374 231.4412 288.2357 227.2794 231.1631 211.2643
## 2017 514.9567 568.5749 326.0315 301.2497 386.5610 296.9067 313.9257 305.0297
## 2018 499.7666 621.0124 336.6904 320.5128 419.2631 344.1061 317.0824 315.7192
## 2019 581.9581 575.4428 385.4211 345.5021 437.3687 316.7390 312.0695 282.7345
## 2020 520.4860 508.0206 334.5558 318.6862 373.7036 314.1695 311.7345 306.6168
## Sep Oct Nov Dec
## 2014 299.8359
## 2015 194.8609 218.6989 260.3259 459.0901
## 2016 203.6424 218.5351 284.7393 454.8984
## 2017 311.4351 329.9140 376.2018 629.1324
## 2018 294.5075 317.4338 422.5271 605.5512
## 2019 263.4784 283.2268 357.3416 580.5339
## 2020 297.6424
We will model the annual % change in demand of product 3 (month by month). We will assume that this product might be competing with another product or might be a complement of other consumer products in the dataset. Then, for this ARIMAX model we have to include the annual % price change of ALL products as independent/explanatory variables.
But before setting up this ARIMAX model, we need to calibrate an ARIMA/SARIMA model for each price of the products in the dataset. In this case, I will provide you with the calibration of the ARIMA/SARIMA models for all prices of the products. I calibrated these models according to what we learned in previous workshops.
We will use the Arima function with a specific calibration for each price:
# Product price 1:
<- Arima(pfabs[,"pfab1"], order = c(1,0,0),
mprice1 seasonal = list(order=c(0,1,0),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice1)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.59807762 0.10544181 5.6721 1.41e-08 ***
## drift 0.00508341 0.00063234 8.0391 9.05e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice1, h=15)
forecastp1 autoplot(forecastp1)
# Product price 2:
<- Arima(pfabs[,"pfab2"], order = c(1,0,0),
mprice2 seasonal = list(order=c(0,1,0),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice2)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.6480305 0.0979253 6.6176 3.651e-11 ***
## drift 0.0053835 0.0010509 5.1228 3.010e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice2, h=15)
forecastp2 autoplot(forecastp2)
# Product price 3:
<- Arima(pfabs[,"pfab3"], order = c(1,0,0),
mprice3 seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice3)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.63551916 0.10995083 5.7800 7.469e-09 ***
## sma1 -0.22374081 0.19500882 -1.1473 0.251242
## drift 0.00217850 0.00072782 2.9932 0.002761 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice3, h=15)
forecastp3 autoplot(forecastp3)
# Product price 4:
<- Arima(pfabs[,"pfab4"], order = c(1,0,0),
mprice4 seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice4)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.66101380 0.09695434 6.8178 9.246e-12 ***
## sma1 -0.56239455 0.16024533 -3.5096 0.0004488 ***
## drift 0.00421852 0.00042551 9.9141 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice4, h=15)
forecastp4 autoplot(forecastp4)
# Product price 5:
<- Arima(pfabs[,"pfab5"], order = c(1,0,0),
mprice5 seasonal = list(order=c(0,1,0),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice5)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.73931832 0.09285911 7.9617 1.697e-15 ***
## drift 0.00556178 0.00095356 5.8326 5.456e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice5, h=15)
forecastp5 autoplot(forecastp5)
# Product price 6:
<- Arima(pfabs[,"pfab6"], order = c(1,0,0),
mprice6 seasonal = list(order=c(1,1,0),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice6)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.8984396 0.0640989 14.0165 < 2.2e-16 ***
## sar1 -0.3927082 0.1315205 -2.9859 0.002827 **
## drift 0.0044928 0.0017715 2.5361 0.011208 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice6, h=15)
forecastp6 autoplot(forecastp6)
# Product price 7:
<- Arima(pfabs[,"pfab7"], order = c(1,0,0),
mprice7 seasonal = list(order=c(0,1,0),period=12),
include.constant = TRUE,
lambda = 0)
# I check the pvalues of the coefficients:
coeftest(mprice7)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.7346684 0.0865368 8.4897 <2e-16 ***
## drift 0.0010131 0.0021806 0.4646 0.6422
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I create and plot the price forecast
<- forecast(mprice7, h=15)
forecastp7 autoplot(forecastp7)
Now that we have a forecast for prices for each product, we can design our first ARIMAX model. We will work with product 3.
The calibration process for an ARIMAX model is the following:
ARIMA-SARIMA calibration for the dependent variable, which is product demand (qfab3) in this case. We have to follow the calibration process we learned in previous workshops.
ARIMAX calibration. With the calibrated ARIMA-SARIMA model, we add the explanatory variables to the model. We start with all explanatory variables and start dropping (one by one) if the corresponding p-value is not significant (pvalue>0.05).
We start calibrating an ARIMA/SARIMA model for the demand of product 3 (qfab3). Since this is the demand of a consumer product, I start checking whether the annual % growth is stationary:
<- diff(log(qfabs[,"qfab3"]),lag=12)
s12.lnfab3 plot(s12.lnfab3)
# I run the Dicky-Fuller test of the annual % difference of demand:
adf.test(s12.lnfab3, k=0)
##
## Augmented Dickey-Fuller Test
##
## data: s12.lnfab3
## Dickey-Fuller = -3.6234, Lag order = 0, p-value = 0.03903
## alternative hypothesis: stationary
Since the p-value<0.05, then I can consider the annual % change of product demand to be stationary. Then, I have to set D = 1 for the ARIMA-SARIMA model and use the log with the parameter lamda=0, to get the annual % change (in continuously compounded).
I continue with the ACF and PACF plots for this variable:
library(astsa)
##
## Attaching package: 'astsa'
## The following object is masked from 'package:forecast':
##
## gas
acf2(s12.lnfab3,max.lag = 12)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
## ACF 0.71 0.68 0.51 0.46 0.38 0.37 0.31 0.24 0.18 0.05 0.1 -0.04
## PACF 0.71 0.35 -0.11 0.01 0.04 0.11 -0.02 -0.14 -0.04 -0.17 0.2 -0.19
Both plots show a typical AR signature. The ac plot shows that s12.lnqfab3 has positive and significant autocorrelations with the first lags, and these autocorrelations diminsh little by little. In the pac plot the autocorrelation of lag3 diminishes drastically and become not significant. Then I start including the first 2 AR terms.
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3 seasonal = list(order=c(0,1,0),period=12),
include.constant = TRUE,
lambda = 0)
coeftest(mqfab3)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.4909805 0.1334787 3.6783 0.0002348 ***
## ar2 0.3434419 0.1332182 2.5780 0.0099362 **
## drift 0.0092503 0.0059405 1.5572 0.1194317
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
I see that both AR coefficients are positive and significant as expected according to the PACF.
I check whether the model residuals behave like a white noise:
acf2(mqfab3$residuals,max.lag = 12)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
## ACF 0.05 0.12 -0.12 -0.10 -0.13 0.08 0.10 0.09 0.06 -0.21 0.06 -0.40
## PACF 0.05 0.12 -0.13 -0.11 -0.09 0.10 0.11 0.03 0.02 -0.22 0.13 -0.36
Now Lag12 is significant and negatively autocorrelated, so I add one seasonal MA term:
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3 seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
lambda = 0)
coeftest(mqfab3)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.6194162 0.1455193 4.2566 2.076e-05 ***
## ar2 0.2479557 0.1455521 1.7036 0.088465 .
## sma1 -0.4199301 0.1323353 -3.1732 0.001508 **
## drift 0.0088409 0.0043133 2.0497 0.040393 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The LAG2 AR term is marginally significant. I will keep it in the model. A rule of thumb to check whether the coefficients are reliable is the following. The sum of the AR and MA terms must be less than 1 and all the coefficients must have an estimation for their pvalues. In this case, the sum of AR coefficients of Lag1 and Lag2 is less than 1. In addition, the sum of the seasonal AR and MA coefficients must be less than 1. In this case, we only have 1 seasonal MA term and it is less than 1 and its pvalue was estimated. Then, I check the residuals of this model:
acf2(mqfab3$residuals,max.lag = 12)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
## ACF 0.01 0.04 -0.1 -0.04 -0.06 0.09 0.06 0.04 0.03 -0.21 0.16 -0.05
## PACF 0.01 0.04 -0.1 -0.04 -0.06 0.08 0.06 0.02 0.04 -0.20 0.19 -0.04
Now the residual of this model look like a white noise since none of its lags are significantly autocorrelated with itself. Then I keep this model for the demand of product 3.
Now I start constructing the corresponding ARIMAX model by including as independent variables the price changes of all products.
To include explanatory variables to my model, I need to add the option xreg and specify a dataset or a variable.
I need to calculate the natural logarithm of the prices since the lambda=0 option only applies to the dependent variable (the qfab), not to the explanatory variables.
<- log(pfabs)
lnpfabs <- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3x seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
xreg = lnpfabs,
lambda = 0)
coeftest(mqfab3x)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.5750171 0.1471092 3.9088 9.276e-05 ***
## ar2 0.2983571 0.1486016 2.0078 0.044668 *
## sma1 -0.5051071 0.1762347 -2.8661 0.004156 **
## drift 0.0080778 0.0055552 1.4541 0.145919
## pfab1 -0.2058647 0.4729665 -0.4353 0.663372
## pfab2 0.3100313 0.3900522 0.7948 0.426703
## pfab3 -1.3078106 0.3298281 -3.9651 7.336e-05 ***
## pfab4 1.2333145 0.5396870 2.2852 0.022299 *
## pfab5 -0.1301127 0.5086985 -0.2558 0.798124
## pfab6 -0.3323815 0.4845033 -0.6860 0.492697
## pfab7 -0.4640113 0.2322750 -1.9977 0.045751 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The coefficients for the independent variables represent price elasticity of demand. In this case, the coefficient of the pfab3 variable will be the direct price elasticity. The coefficients for the other price variables will be the cross-elasticities. It might be possible that the price change of one product not only affects its own demand (direct price elasticity), but it might influence the demand of another product (cross-elasticity).
We have to check for significance of each elasticity coefficient. You have to identify the independent variable with the biggest p-value and eliminate it from the ARIMAX model. In this case, the coefficient of pfab5 has the highest pvalue, then we drop it from the model. We continue this process until all the independent variables are marginally significant (p-value<0.10) or significant (pvalue<0.05)
# I drop pfab5:
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3x seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
xreg = lnpfabs[,c("pfab1","pfab2","pfab3","pfab4","pfab6","pfab7")],
lambda = 0)
coeftest(mqfab3x)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.5790133 0.1466517 3.9482 7.873e-05 ***
## ar2 0.3038159 0.1473731 2.0615 0.039251 *
## sma1 -0.5016069 0.1753886 -2.8600 0.004237 **
## drift 0.0074759 0.0051811 1.4429 0.149044
## pfab1 -0.2069226 0.4708299 -0.4395 0.660310
## pfab2 0.3111542 0.3878632 0.8022 0.422422
## pfab3 -1.3121031 0.3283405 -3.9962 6.438e-05 ***
## pfab4 1.2288795 0.5374969 2.2863 0.022237 *
## pfab6 -0.3440459 0.4823139 -0.7133 0.475646
## pfab7 -0.4624882 0.2305094 -2.0064 0.044816 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Now pfab1 has the highest p-value, so I drop it:
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3x seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
xreg = lnpfabs[,c("pfab2","pfab3","pfab4","pfab6","pfab7")],
lambda = 0)
coeftest(mqfab3x)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.5843708 0.1463621 3.9926 6.534e-05 ***
## ar2 0.3046634 0.1461676 2.0843 0.03713 *
## sma1 -0.5045860 0.1760256 -2.8665 0.00415 **
## drift 0.0064728 0.0047912 1.3510 0.17670
## pfab2 0.2894457 0.3838649 0.7540 0.45083
## pfab3 -1.3171963 0.3286207 -4.0083 6.117e-05 ***
## pfab4 1.2418911 0.5394687 2.3021 0.02133 *
## pfab6 -0.3214826 0.4825860 -0.6662 0.50530
## pfab7 -0.4639166 0.2299638 -2.0173 0.04366 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I drop pfab6:
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3x seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
xreg = lnpfabs[,c("pfab2","pfab3","pfab4","pfab7")],
lambda = 0)
coeftest(mqfab3x)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.5610500 0.1418341 3.9557 7.632e-05 ***
## ar2 0.3081099 0.1461814 2.1077 0.035055 *
## sma1 -0.4609427 0.1569757 -2.9364 0.003321 **
## drift 0.0055048 0.0043414 1.2680 0.204813
## pfab2 0.2976480 0.3844899 0.7741 0.438849
## pfab3 -1.3261834 0.3328866 -3.9839 6.780e-05 ***
## pfab4 1.1170707 0.5032600 2.2197 0.026441 *
## pfab7 -0.4932592 0.2293477 -2.1507 0.031499 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# I drop pfab2:
<- Arima(qfabs[,"qfab3"], order = c(2,0,0),
mqfab3x seasonal = list(order=c(0,1,1),period=12),
include.constant = TRUE,
xreg = lnpfabs[,c("pfab3","pfab4","pfab7")],
lambda = 0)
coeftest(mqfab3x)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.5813125 0.1430666 4.0632 4.84e-05 ***
## ar2 0.2629981 0.1389580 1.8926 0.058405 .
## sma1 -0.4628229 0.1566977 -2.9536 0.003141 **
## drift 0.0067775 0.0036500 1.8568 0.063335 .
## pfab3 -1.2701872 0.3314490 -3.8322 0.000127 ***
## pfab4 1.1607718 0.5064396 2.2920 0.021904 *
## pfab7 -0.5120226 0.2350779 -2.1781 0.029399 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Now all the pvalues of the independent variables and the arima terms are less than 0.10, so I keep this ARIMAX model for the demand of product 3.
How can we interpret this ARIMAX model?
I start with the effect of the independent variables. The direct elasticity of product 3 is -1.2701872. This means that for each 1% annual change in price of product 3, its annual % change in demand will be (on average) about -1.2701872%, after considering the effect of cross elasticity of products 4 and 7, and also considering the effect of its own annual % growth in demand of the previous 2 months and also considering the effect of external factors (the error/shock) of 12 months ago.
Since its direct elasticity is less than -1, we can consider this product as elastic since it is very sensitive to price changes.
Regarding the cross elasticities, we have strong statistical evidence to say that product 4 is a competence of product 3 since the cross elasticity of product 4 is positive and significant: it is 1.1607718. This means that for each 1% annual increase in price of product 4, the expected annual %change in demand of product 3 will be about 1.1607718%, after considering the effect of the other variables in the model and the AR and seasonal MA terms.
The cross elasticity of product 7 is significant and negative; it is -0.5120226. This is a sign of complementary between product 7 and product 3. This means that the effect of price annual change of product 7 is negatively and significantly related to the annual change in demand of product 3. In other words, for 1% annual increase in price of product 7, the annual % change in demand of product 3 will be about -0.5120226, after considering the effect of the rest of the variables and the AR and seasonal MA terms.
After considering the effect of price change of products 4 and 7, the annual % change in demand of product 4 is positively and significantly related with its own annual % change of the 2 previous months. In addition, external factors (the shock/error) of 12 months ago influence the annual % change in demand of product 4 in a negative way.
Now we can run a forecast of the product 3 demand for the next 15 months. To do this, do the following:
# Create a dataset for the forecast log prices of the explanatory variables:
<- cbind(forecastp3$mean,forecastp4$mean,forecastp7$mean)
lnpricesf <- log(lnpricesf)
lnpricesf <- forecast(mqfab3x,xreg=lnpricesf) qfab3forecast
## Warning in forecast.forecast_ARIMA(mqfab3x, xreg = lnpricesf): xreg contains
## different column names from the xreg used in training. Please check that the
## regressors are in the same order.
autoplot(qfab3forecast)
Now that we have a prediction of product 3 demand in quantity and product 3 price, we can get the prediction of value sales for this product.
HOW YOU CAN DO THIS IN R?
You have to calibrate an ARIMA model for product 4 following the method we learned here. You have to show and explain your steps, and also you have to INTERPRET your final model, and do a prediction for the next 15 months.
Go to Canvas and respond Quiz 6. You will have 3 attempts. Questions in this Quiz are related to concepts of the readings related to this Workshop.
The grade of this Workshop will be the following:
Remember that you have to submit your .html file through Canvas BEFORE NEXT CLASS.