In this week’s discussion post, I continued my analysis on the Financial Times leading equity prices index, presented quarterly from 1960 to 1971.

Data Import and preperation

library(readr)
financial_times_index_leading_eq <- read_csv("~/Desktop/PF/financial-times-index-leading-eq.csv")
## Parsed with column specification:
## cols(
##   Quarter = col_character(),
##   `Financial Times index leading equity prices (quarterly) 1960 ? 1971` = col_double()
## )
financialtimes <- financial_times_index_leading_eq
require(fpp)
## Loading required package: fpp
## Loading required package: forecast
## Warning: package 'forecast' was built under R version 3.4.2
## Warning in as.POSIXlt.POSIXct(Sys.time()): unknown timezone 'zone/tz/2018c.
## 1.0/zoneinfo/America/New_York'
## Loading required package: fma
## Loading required package: expsmooth
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: tseries
fti=ts(financialtimes$`Financial Times index leading equity prices (quarterly) 1960 ? 1971`,frequency=4,start=c(1960,1))
plot(fti, xlab="Years", ylab="Index", main="History of Financial Times Index, Leading Equity Prices")

#make trainig and test data set
#training set 1960 to 1968, test set 1969 to 1971 (split 75%/25%)
train=financialtimes[1:36,]
test=financialtimes[37:48,]
ftitrain=ts(train$`Financial Times index leading equity prices (quarterly) 1960 ? 1971`,frequency=4,start=c(1960,1))
plot(ftitrain, xlab="Years", ylab="Index", main="History of Financial Times Index, Leading Equity Prices")

ftitest=ts(test$`Financial Times index leading equity prices (quarterly) 1960 ? 1971`,frequency=4,start=c(1969,1))
plot(ftitest, xlab="Years", ylab="Index", main="History of Financial Times Index, Leading Equity Prices")

R Markdown

I fit 5 separate models: simple exponential smoothing, Holt’s method, Holt’s method with exponential trend, Damped Holt’s method, Damped Holt’s method with exponential trend. Then I compared their respected ME, RMSE, MAE, MPE, MAPE, and MASE based on the test set.

fit1 <- ses(ftitrain)
fit2 <- holt(ftitrain)
fit3 <- holt(ftitrain, exponential = TRUE)
fit4 <- holt(ftitrain, damped = TRUE)
fit5 <- holt(ftitrain, exponential = TRUE, damped = TRUE)
#results of fit1- Simple exponential smoothing
fit1$model
## Simple exponential smoothing 
## 
## Call:
##  ses(y = ftitrain) 
## 
##   Smoothing parameters:
##     alpha = 0.9999 
## 
##   Initial states:
##     l = 323.7831 
## 
##   sigma:  21.0118
## 
##      AIC     AICc      BIC 
## 354.2526 355.0026 359.0032
plot(residuals(fit1))

hist(residuals(fit1))

accuracy(fit1, ftitest)
##                       ME      RMSE       MAE         MPE      MAPE
## Training set    4.631492  21.01176  16.83127   0.9730415  4.912315
## Test set     -107.070090 116.58858 107.17007 -29.6059365 29.626299
##                   MASE      ACF1 Theil's U
## Training set 0.4493205 0.1125857        NA
## Test set     2.8609680 0.4583051  3.897149
#results of fit2- Holt's method
fit2$model
## Holt's method 
## 
## Call:
##  holt(y = ftitrain) 
## 
##   Smoothing parameters:
##     alpha = 0.9999 
##     beta  = 0.0846 
## 
##   Initial states:
##     l = 330.3985 
##     b = 1.2013 
## 
##   sigma:  20.736
## 
##      AIC     AICc      BIC 
## 357.3013 359.3013 365.2189
plot(residuals(fit2))

hist(residuals(fit2))

accuracy(fit2, ftitest)
##                      ME      RMSE       MAE         MPE      MAPE
## Training set    3.11599  20.73597  17.14099   0.6250055  5.038737
## Test set     -165.89307 181.25212 165.89307 -45.8614594 45.861459
##                   MASE       ACF1 Theil's U
## Training set 0.4575887 0.02809722        NA
## Test set     4.4286129 0.60021631   6.13974
#results of fit3- Holt's method with exponential trend 
fit3$model
## Holt's method with exponential trend 
## 
## Call:
##  holt(y = ftitrain, exponential = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.9862 
##     beta  = 0.0882 
## 
##   Initial states:
##     l = 326.6728 
##     b = 0.9967 
## 
##   sigma:  0.0609
## 
##      AIC     AICc      BIC 
## 356.0748 358.0748 363.9924
plot(residuals(fit3))

hist(residuals(fit3))

accuracy(fit3, ftitest)
##                      ME      RMSE       MAE         MPE      MAPE
## Training set    3.14422  20.56482  16.91247   0.6641901  4.970556
## Test set     -193.45974 212.73871 193.45974 -53.5172105 53.517210
##                   MASE       ACF1 Theil's U
## Training set 0.4514884 0.01092404        NA
## Test set     5.1645214 0.63417514  7.243989
#results of fit4- Damped Holt's method 
fit4$model
## Damped Holt's method 
## 
## Call:
##  holt(y = ftitrain, damped = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.9408 
##     beta  = 0.2304 
##     phi   = 0.8 
## 
##   Initial states:
##     l = 326.9279 
##     b = -4.7692 
## 
##   sigma:  20.5654
## 
##      AIC     AICc      BIC 
## 358.7066 361.6031 368.2077
plot(residuals(fit4))

hist(residuals(fit4))

accuracy(fit4, ftitest)
##                       ME      RMSE       MAE         MPE      MAPE
## Training set    3.446733  20.56539  16.79445   0.7659452  4.947072
## Test set     -138.523408 149.28874 138.52341 -38.1826381 38.182638
##                   MASE        ACF1 Theil's U
## Training set 0.4483378 -0.03290542        NA
## Test set     3.6979637  0.51229701  4.999817
#results of fit5- Damped Holt's method with exponential trend 
fit5$model
## Damped Holt's method with exponential trend 
## 
## Call:
##  holt(y = ftitrain, damped = TRUE, exponential = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.9196 
##     beta  = 0.2281 
##     phi   = 0.8 
## 
##   Initial states:
##     l = 331.5325 
##     b = 0.9765 
## 
##   sigma:  0.0607
## 
##      AIC     AICc      BIC 
## 357.8104 360.7070 367.3115
plot(residuals(fit5))

hist(residuals(fit5))

accuracy(fit5, ftitest)
##                       ME      RMSE       MAE         MPE      MAPE
## Training set    3.043918  20.46064  16.74782   0.6581428  4.937418
## Test set     -152.840917 164.69765 152.84092 -42.1209891 42.120989
##                  MASE        ACF1 Theil's U
## Training set 0.447093 -0.02624089        NA
## Test set     4.080178  0.53599862  5.524792

Forecasts from Holt’s Method with Exponetial Trend

Examining the training set models on the test set, these models do not do the greatest job in forecasting the Financial Times Index. The best one seen in the diagram that fits the data the best is the SES model (Simple Exponential Smoothing Model). The model has the lowest variance and bias calculations when examining the ME, RMSE, MAE, MPE, MAPE, and MASE based on the test set.

plot(fit3, type="o", ylab="Financial Times Index, Leading Equity Prices", xlab = "Year", 
     flwd=1, plot.conf=FALSE)
## Warning in plot.window(xlim, ylim, log, ...): "plot.conf" is not a
## graphical parameter
## Warning in title(main = main, xlab = xlab, ylab = ylab, ...): "plot.conf"
## is not a graphical parameter
## Warning in axis(1, ...): "plot.conf" is not a graphical parameter
## Warning in axis(2, ...): "plot.conf" is not a graphical parameter
## Warning in box(...): "plot.conf" is not a graphical parameter
lines(ts(test$`Financial Times index leading equity prices (quarterly) 1960 ? 1971`,frequency=4,start=c(1969,1)),type="o")
lines(fit1$mean,col=2)
lines(fit2$mean,col=3)
lines(fit4$mean,col=5)
lines(fit5$mean,col=6)
legend("topleft", lty=1, pch=1, col=1:6,
       c("Data","SES","Holt's","Exponential","Additive Damped","Multiplicative Damped"))

Holt and Winters Method

Here the Holt and Winters additive and multiplicative models are presented.

#fit 6 Holt-Winters' additive method 
fit6 <- hw(ftitrain,seasonal="additive")
fit6$model
## Holt-Winters' additive method 
## 
## Call:
##  hw(y = ftitrain, seasonal = "additive") 
## 
##   Smoothing parameters:
##     alpha = 0.9923 
##     beta  = 0.1353 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 331.9023 
##     b = -0.7286 
##     s=-2.3141 -3.6084 7.0346 -1.1121
## 
##   sigma:  19.5196
## 
##      AIC     AICc      BIC 
## 360.9487 367.8718 375.2004
plot(residuals(fit6))

hist(residuals(fit6))

accuracy(fit6, ftitest)
##                       ME      RMSE       MAE         MPE      MAPE
## Training set    3.203009  19.51957  16.30627   0.7292657  4.752153
## Test set     -168.509193 185.77199 168.50919 -45.8268908 45.826891
##                   MASE       ACF1 Theil's U
## Training set 0.4353055 0.04570892        NA
## Test set     4.4984518 0.50616003   6.35718
#fit 6 Holt-Winters' multiplicative method 
fit7 <- hw(ftitrain,seasonal="multiplicative")
fit7$model
## Holt-Winters' multiplicative method 
## 
## Call:
##  hw(y = ftitrain, seasonal = "multiplicative") 
## 
##   Smoothing parameters:
##     alpha = 0.9999 
##     beta  = 0.2059 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 329.9149 
##     b = 1.698 
##     s=0.9916 0.9952 1.0211 0.9921
## 
##   sigma:  0.0591
## 
##      AIC     AICc      BIC 
## 362.0501 368.9732 376.3018
plot(residuals(fit7))

hist(residuals(fit7))

accuracy(fit7, ftitest)
##                       ME      RMSE      MAE         MPE      MAPE
## Training set    2.262608  19.63542  16.5684   0.4961539  4.856335
## Test set     -186.900494 206.10813 186.9005 -50.8265343 50.826534
##                   MASE        ACF1 Theil's U
## Training set 0.4423032 -0.01038687        NA
## Test set     4.9894184  0.50815901  7.050579
#plot
plot(fit6, type="o", ylab="Financial Times Index, Leading Equity Prices", xlab = "Year", 
     flwd=1, plot.conf=FALSE)
## Warning in plot.window(xlim, ylim, log, ...): "plot.conf" is not a
## graphical parameter
## Warning in title(main = main, xlab = xlab, ylab = ylab, ...): "plot.conf"
## is not a graphical parameter
## Warning in axis(1, ...): "plot.conf" is not a graphical parameter
## Warning in axis(2, ...): "plot.conf" is not a graphical parameter
## Warning in box(...): "plot.conf" is not a graphical parameter
lines(ts(test$`Financial Times index leading equity prices (quarterly) 1960 ? 1971`,frequency=4,start=c(1969,1)),type="o")
lines(fitted(fit6),col="red",lty=2)
lines(fitted(fit7),col="green",lty=2)
lines(fit6$mean,type="o",col="red")
lines(fit7$mean,type="o",col="green")
legend("topleft",lty=1,pch=1,col=c(1,2,3),c("data","Holt Winters' Additive","Holt Winters' Multiplicative"))

Based on the models above, the best model for the Financial Times leading equities index is the SES model (Simple Exponential Smoothing Model). The model has the lowest variance and bias calculations when examining the ME, RMSE, MAE, MPE, MAPE, and MASE overall based on the test set. I believe the Holt- Winter models preformed very poorly due to the heavy reliance of seasonality in these methods, something equities may not have. The SES model also is most suitable for forecasting data that has no typical trend or seasonal pattern. This is seen in this data, as the equity index is extremely volatile.