Purpose:Understand the difference between additive and multiplicative decomposition. Solidifying understanding of deterministic trend forecasts as well as in- and out-of-sample forecasts and their assessments.Deadline: Saturday, September 30, 2017

First, we have to load our Airline Passengers data. If you have questions about he data you can find more information via executing `?AirPassengers`

in the `R`

console.

```
data("AirPassengers")
AP.ts <- AirPassengers
```

The data is available as a .csv-file here. Please ensure that you are able to save files such as this one locally on your computer. Make sure you know how to set a directory in `R`

using the `setwd()`

and check what your working directory is via `getwd()`

.

We split the \(12\times 12\) observations on Airline Passengers into three subperiods of equal length. We then split these three subperiod into two subsample, an in-sample of the first two years and an out-of-sample period of two years. So altogether there are six periods:

Period ID | Period Type | Start | End |
---|---|---|---|

1.1 | in-sample | Jan 1949 | Dec 1950 |

1.2 | out-of-sample | Jan 1951 | Dec 1952 |

2.1 | in-sample | Jan 1953 | Dec 1954 |

2.2 | out-of-sample | Jan 1955 | Dec 1956 |

3.1 | in-sample | Jan 1957 | Dec 1958 |

3.2 | out-of-sample | Jan 1959 | Dec 1960 |

Questions 1-6 refer to forecast using the `AP.ts`

time series.

Using a linear trend model in period 1.1, 2.1, and 3.1 to forecast values in periods 1.2, 2.2, and 3.2 respectively.

**Question 1**

What is the MEA for the first out-of-sample period 1.2 using the linear trend model estimated on in-sample period 1.1 for the series `AP.ts`

. *(0.5 points)*

**Question 4**

What is the RMSE for the first out-of-sample period 1.2 using the linear trend model estimated on in-sample period 1.1 for the series `AP.ts`

. *(0.5 points)*

**Question 7**

What is the MAPE for the first out-of-sample period 1.2 using the linear trend model estimated on in-sample period 1.1 for the series `AP.ts`

. *(0.5 points)*

```
library(forecast)
AP.ts <- AirPassengers
mod.1.1 <- lm(window(AP.ts,start=c(1949,1),end=c(1950,12))~window(time(AP.ts),start=c(1949,1),end=c(1950,12)))
```

The in-sample fit is easy:

`accuracy(mod.1.1)`

```
## ME RMSE MAE MPE MAPE MASE
## Training set -5.918118e-16 15.81446 13.20374 -1.378989 9.978599 0.9593033
```

Let’s do the out-of-sample forecast “manually”. Here’s the constant and coefficient on the deterministic time trend

`mod.1.1$coefficients[1]`

```
## (Intercept)
## -22574.52
```

`mod.1.1$coefficients[2]`

```
## window(time(AP.ts), start = c(1949, 1), end = c(1950, 12))
## 11.64522
```

Given this is a simple linear trend model, we can easily compute the forecasts:

`f.1.2 <- mod.1.1$coefficients[1] + mod.1.1$coefficients[2]*seq(1951,1953,length.out=25)[1:24]`

Let’s get the forecast errors …

`e.1.2 <- as.numeric(window(AP.ts,start=c(1951,1),end=c(1952,12))) - f.1.2`

… and plot them …

```
plot(e.1.2,las=1,col="blue",lwd=2,ylab="",type="h",
main="Out-of-Sample Forecast Error in Period 1.2") ; abline(h=0)
library(Hmisc)
minor.tick(nx=5)
```