Number 1 A. True. Because if they are not normally distributed then there could be other information that you are missing. B. False. A model with small residuals could indicate that the model is overfit. C. False. There are 4 methods to elavulate error and depending on what you are looking for another method can be a better fit. D. False. If your model doesn’t forecast well then you might wnt to think about using a differnt method. If you just make it more complicated then you might end up overfitting. E. True. Although when you have 2 models that are relatively close then it is better to o with the simpler model.

Number 2

library(fpp)
## Warning: package 'fpp' was built under R version 3.4.4
## Loading required package: forecast
## Warning: package 'forecast' was built under R version 3.4.4
## Loading required package: fma
## Warning: package 'fma' was built under R version 3.4.4
## Loading required package: expsmooth
## Warning: package 'expsmooth' was built under R version 3.4.4
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.4.4
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.4.4
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: tseries
## Warning: package 'tseries' was built under R version 3.4.4
autoplot(dowjones)

rwf(dowjones,3, drift=TRUE)
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 79       121.3636 120.8129 121.9143 120.5214 122.2059
## 80       121.4973 120.7085 122.2860 120.2910 122.7035
## 81       121.6309 120.6529 122.6089 120.1352 123.1266
autoplot(dowjones)+
  autolayer(rwf(dowjones,4, drift=TRUE), series = "Drift", PI = FALSE)+
    autolayer(snaive(dowjones,4), series = "Seasonal Naive", PI = FALSE)+
     autolayer(meanf(dowjones,4), series = "Mean", PI = FALSE)+
      autolayer(naive(dowjones,4), series = "Naive", PI = FALSE)

Drift is the best option for this data. The mean is not a good forecast for this because of the wide range of data. Seasonal and naive are the same in this one for there is not much seasonality therefore creating a a flat forecast.

Number 3

autoplot(ibmclose)

train <- subset(ibmclose, end = 300)
test <- subset(ibmclose, start = 301)

autoplot(train)

autoplot(test)

ibm1 <- naive(train, 69)
ibm2 <- snaive(train, 69)
ibm3 <- meanf(train, 69)
ibm4 <- rwf(train, 69, drift = TRUE)

accuracy(ibm1, test)
##                      ME      RMSE      MAE         MPE     MAPE     MASE
## Training set -0.2809365  7.302815  5.09699 -0.08262872 1.115844 1.000000
## Test set     -3.7246377 20.248099 17.02899 -1.29391743 4.668186 3.340989
##                   ACF1 Theil's U
## Training set 0.1351052        NA
## Test set     0.9314689  2.973486
accuracy(ibm2, test)
##                      ME      RMSE      MAE         MPE     MAPE     MASE
## Training set -0.2809365  7.302815  5.09699 -0.08262872 1.115844 1.000000
## Test set     -3.7246377 20.248099 17.02899 -1.29391743 4.668186 3.340989
##                   ACF1 Theil's U
## Training set 0.1351052        NA
## Test set     0.9314689  2.973486
accuracy(ibm3, test)
##                         ME      RMSE       MAE        MPE     MAPE
## Training set  1.660438e-14  73.61532  58.72231  -2.642058 13.03019
## Test set     -1.306180e+02 132.12557 130.61797 -35.478819 35.47882
##                  MASE      ACF1 Theil's U
## Training set 11.52098 0.9895779        NA
## Test set     25.62649 0.9314689  19.05515
accuracy(ibm4, test)
##                        ME      RMSE       MAE         MPE     MAPE
## Training set 2.870480e-14  7.297409  5.127996 -0.02530123 1.121650
## Test set     6.108138e+00 17.066963 13.974747  1.41920066 3.707888
##                  MASE      ACF1 Theil's U
## Training set 1.006083 0.1351052        NA
## Test set     2.741765 0.9045875  2.361092
checkresiduals(ibm4)

## 
##  Ljung-Box test
## 
## data:  Residuals from Random walk with drift
## Q* = 22.555, df = 9, p-value = 0.007278
## 
## Model df: 1.   Total lags used: 10

Drift looks to be the best fit forecast for this data set. The residuals look to be close to white noise with little skew to the left. There appears to be correlation accoring to the acf.

Number 4

autoplot(hsales)

help("hsales")
## starting httpd help server ... done
train <- subset(hsales, end = length(hsales) - (12*2))
test <- subset(hsales, start = length(hsales) - (12*2) + 1)

autoplot(train)

autoplot(test)

sales1 <- naive(train, 24)
sales2 <- snaive(train, 24)
sales3 <- meanf(train, 24)
sales4 <- rwf(train, 24, drift = TRUE)

accuracy(sales1, test)
##                     ME     RMSE      MAE       MPE      MAPE      MASE
## Training set -0.008000 6.301111 5.000000 -0.767457  9.903991 0.5892505
## Test set      2.791667 8.628924 7.208333  2.858639 12.849194 0.8495028
##                   ACF1 Theil's U
## Training set 0.1824472        NA
## Test set     0.5377994  1.098358
accuracy(sales2, test)
##                     ME      RMSE      MAE       MPE      MAPE      MASE
## Training set 0.1004184 10.582214 8.485356 -2.184269 17.633696 1.0000000
## Test set     1.0416667  5.905506 4.791667  0.972025  8.545729 0.5646984
##                   ACF1 Theil's U
## Training set 0.8369786        NA
## Test set     0.1687797 0.7091534
accuracy(sales3, test)
##                        ME      RMSE      MAE       MPE     MAPE      MASE
## Training set 3.510503e-15 12.162811 9.532738 -6.144876 20.38306 1.1234341
## Test set     3.839475e+00  9.022555 7.561587  4.779122 13.26183 0.8911338
##                   ACF1 Theil's U
## Training set 0.8661998        NA
## Test set     0.5377994  1.131713
accuracy(sales4, test)
##                        ME     RMSE      MAE        MPE      MAPE      MASE
## Training set 1.506410e-15 6.301106 4.999872 -0.7511048  9.903063 0.5892354
## Test set     2.891667e+00 8.658795 7.249000  3.0426108 12.901697 0.8542954
##                   ACF1 Theil's U
## Training set 0.1824472        NA
## Test set     0.5378711  1.100276
checkresiduals(sales2)

## 
##  Ljung-Box test
## 
## data:  Residuals from Seasonal naive method
## Q* = 682.2, df = 24, p-value < 2.2e-16
## 
## Model df: 0.   Total lags used: 24

Seasonal naive looks to be the best fit forecast for this data set. The residuals look to be noise but the acf and histogram tell us that they are not noise. It looks to be normal with a slight skew to the left.

Number 5

checkresiduals(snaive(WWWusage))

## 
##  Ljung-Box test
## 
## data:  Residuals from Seasonal naive method
## Q* = 145.58, df = 10, p-value < 2.2e-16
## 
## Model df: 0.   Total lags used: 10
checkresiduals(snaive(bricksq))

## 
##  Ljung-Box test
## 
## data:  Residuals from Seasonal naive method
## Q* = 233.2, df = 8, p-value < 2.2e-16
## 
## Model df: 0.   Total lags used: 8

Both residual graphs appear to be nosie at first glance, but the acf graph tells us they are not. The WWWusage data has a normal distrubution for the residuals. The bricksq data is skewed to the left for the residuals.

Number 6

library(fpp)

autoplot(dole)

dole1 <- cbind(Monthly = dole,
               DailyAverage = dole/monthdays(dole))

autoplot(dole1, facet = TRUE)

For the dole data set, I did a calendar adjustment to smooth out the graph from daily to monthly observations.

autoplot(usgdp)

cpi <- read.csv("CPIAUCNS.csv")

cpi$DATE <- as.Date(cpi$DATE, format = "%m/%d/%Y")

start <- as.POSIXct("1947-01-01")
end <- as.POSIXct("2006-01-01")

cpi <- cpi[as.POSIXct(cpi$DATE) >= start & as.POSIXct(cpi$DATE) <= end,]

x <- seq(1,length(cpi[,1]) - 1,3)

cpi_q <- seq(1,length(cpi[,1]) - 1,3)
x
##   [1]   1   4   7  10  13  16  19  22  25  28  31  34  37  40  43  46  49
##  [18]  52  55  58  61  64  67  70  73  76  79  82  85  88  91  94  97 100
##  [35] 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151
##  [52] 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199 202
##  [69] 205 208 211 214 217 220 223 226 229 232 235 238 241 244 247 250 253
##  [86] 256 259 262 265 268 271 274 277 280 283 286 289 292 295 298 301 304
## [103] 307 310 313 316 319 322 325 328 331 334 337 340 343 346 349 352 355
## [120] 358 361 364 367 370 373 376 379 382 385 388 391 394 397 400 403 406
## [137] 409 412 415 418 421 424 427 430 433 436 439 442 445 448 451 454 457
## [154] 460 463 466 469 472 475 478 481 484 487 490 493 496 499 502 505 508
## [171] 511 514 517 520 523 526 529 532 535 538 541 544 547 550 553 556 559
## [188] 562 565 568 571 574 577 580 583 586 589 592 595 598 601 604 607 610
## [205] 613 616 619 622 625 628 631 634 637 640 643 646 649 652 655 658 661
## [222] 664 667 670 673 676 679 682 685 688 691 694 697 700 703 706
num <- 1
for (i in x){
  print(cpi[i,2])
  cpi_avg <- (cpi[i,2] + cpi[i + 1,2] + cpi[i + 2,2])/3
  cpi_q[num] <- cpi_avg
  num <- num + 1
  }
## [1] 21.5
## [1] 21.9
## [1] 22.5
## [1] 23.1
## [1] 23.5
## [1] 23.9
## [1] 24.5
## [1] 24.2
## [1] 23.8
## [1] 23.8
## [1] 23.8
## [1] 23.8
## [1] 23.5
## [1] 23.7
## [1] 24.3
## [1] 24.7
## [1] 25.7
## [1] 25.9
## [1] 25.9
## [1] 26.4
## [1] 26.3
## [1] 26.4
## [1] 26.7
## [1] 26.7
## [1] 26.5
## [1] 26.7
## [1] 26.9
## [1] 26.9
## [1] 26.9
## [1] 26.9
## [1] 26.9
## [1] 26.8
## [1] 26.7
## [1] 26.7
## [1] 26.8
## [1] 26.9
## [1] 26.8
## [1] 27
## [1] 27.3
## [1] 27.5
## [1] 27.7
## [1] 28
## [1] 28.3
## [1] 28.4
## [1] 28.6
## [1] 28.9
## [1] 28.9
## [1] 29
## [1] 28.9
## [1] 29
## [1] 29.2
## [1] 29.4
## [1] 29.4
## [1] 29.5
## [1] 29.6
## [1] 29.8
## [1] 29.8
## [1] 29.8
## [1] 29.9
## [1] 30
## [1] 30.1
## [1] 30.2
## [1] 30.3
## [1] 30.4
## [1] 30.4
## [1] 30.5
## [1] 30.7
## [1] 30.8
## [1] 30.9
## [1] 30.9
## [1] 31
## [1] 31.2
## [1] 31.2
## [1] 31.4
## [1] 31.6
## [1] 31.7
## [1] 32
## [1] 32.3
## [1] 32.7
## [1] 32.9
## [1] 32.9
## [1] 33.2
## [1] 33.5
## [1] 33.8
## [1] 34.2
## [1] 34.5
## [1] 35
## [1] 35.4
## [1] 35.8
## [1] 36.4
## [1] 37
## [1] 37.5
## [1] 38
## [1] 38.6
## [1] 39
## [1] 39.6
## [1] 39.9
## [1] 40.3
## [1] 40.8
## [1] 40.9
## [1] 41.3
## [1] 41.6
## [1] 42
## [1] 42.4
## [1] 42.9
## [1] 43.9
## [1] 45.1
## [1] 45.9
## [1] 47.2
## [1] 48.6
## [1] 50
## [1] 51.5
## [1] 52.5
## [1] 53.2
## [1] 54.3
## [1] 55.3
## [1] 55.8
## [1] 56.5
## [1] 57.4
## [1] 58
## [1] 59.1
## [1] 60.3
## [1] 61.2
## [1] 61.9
## [1] 62.9
## [1] 64.5
## [1] 66
## [1] 67.4
## [1] 69.1
## [1] 71.5
## [1] 73.8
## [1] 75.9
## [1] 78.9
## [1] 81.8
## [1] 83.3
## [1] 85.5
## [1] 87.9
## [1] 89.8
## [1] 92.3
## [1] 93.7
## [1] 94.6
## [1] 95.8
## [1] 97.7
## [1] 98
## [1] 97.9
## [1] 99.2
## [1] 100.2
## [1] 101.2
## [1] 102.4
## [1] 103.4
## [1] 104.5
## [1] 105.3
## [1] 106
## [1] 107.3
## [1] 108
## [1] 109
## [1] 109.3
## [1] 108.9
## [1] 109.7
## [1] 110.4
## [1] 111.6
## [1] 113.1
## [1] 114.4
## [1] 115.4
## [1] 116
## [1] 117.5
## [1] 119
## [1] 120.3
## [1] 121.6
## [1] 123.8
## [1] 124.6
## [1] 125.9
## [1] 128
## [1] 129.2
## [1] 131.6
## [1] 133.8
## [1] 134.8
## [1] 135.6
## [1] 136.6
## [1] 137.8
## [1] 138.6
## [1] 139.7
## [1] 140.9
## [1] 142
## [1] 143.1
## [1] 144.2
## [1] 144.8
## [1] 145.8
## [1] 146.7
## [1] 147.5
## [1] 149
## [1] 149.7
## [1] 150.9
## [1] 152.2
## [1] 152.9
## [1] 153.6
## [1] 154.9
## [1] 156.6
## [1] 157.3
## [1] 158.6
## [1] 159.6
## [1] 160.1
## [1] 160.8
## [1] 161.5
## [1] 161.9
## [1] 162.8
## [1] 163.4
## [1] 164
## [1] 164.5
## [1] 166.2
## [1] 167.1
## [1] 168.3
## [1] 169.8
## [1] 171.5
## [1] 172.8
## [1] 174.1
## [1] 175.8
## [1] 177.7
## [1] 177.5
## [1] 177.4
## [1] 177.8
## [1] 179.8
## [1] 180.7
## [1] 181.3
## [1] 183.1
## [1] 183.5
## [1] 184.6
## [1] 184.5
## [1] 186.2
## [1] 189.1
## [1] 189.5
## [1] 191
## [1] 191.8
## [1] 194.4
## [1] 196.4
## [1] 197.6
cpi_q
##   [1]  21.76667  22.03333  22.83333  23.40000  23.56667  24.13333  24.46667
##   [8]  24.10000  23.83333  23.80000  23.80000  23.63333  23.56667  23.86667
##  [15]  24.43333  25.03333  25.76667  25.90000  26.06667  26.46667  26.33333
##  [22]  26.53333  26.70000  26.66667  26.56667  26.76667  26.93333  26.90000
##  [29]  26.86667  26.90000  26.83333  26.73333  26.70000  26.73333  26.86667
##  [36]  26.83333  26.83333  27.20000  27.40000  27.56667  27.80000  28.13333
##  [43]  28.30000  28.46667  28.76667  28.93333  28.90000  28.96667  28.93333
##  [50]  29.10000  29.30000  29.36667  29.43333  29.56667  29.66667  29.80000
##  [57]  29.80000  29.86667  29.96667  30.00000  30.13333  30.23333  30.36667
##  [64]  30.40000  30.46667  30.60000  30.73333  30.86667  30.90000  31.00000
##  [71]  31.06667  31.20000  31.30000  31.53333  31.63333  31.76667  32.13333
##  [78]  32.40000  32.76667  32.90000  33.00000  33.30000  33.60000  33.93333
##  [85]  34.30000  34.70000  35.13333  35.50000  36.06667  36.60000  37.13333
##  [92]  37.66667  38.23333  38.80000  39.20000  39.73333  40.00000  40.53333
##  [99]  40.83333  41.03333  41.40000  41.73333  42.13333  42.50000  43.26667
## [106]  44.13333  45.30000  46.23333  47.66667  49.00000  50.56667  51.83333
## [113]  52.70000  53.66667  54.60000  55.46667  55.93333  56.80000  57.63333
## [120]  58.23333  59.53333  60.66667  61.40000  62.16667  63.40000  65.13333
## [127]  66.53333  67.80000  69.83333  72.30000  74.53333  76.80000  80.00000
## [134]  82.40000  84.03333  86.26667  88.50000  90.66667  92.96667  94.00000
## [141]  94.66667  96.76667  97.93333  97.80000  98.13333  99.53333 100.63333
## [148] 101.46667 102.70000 103.73333 104.93333 105.36667 106.43333 107.56667
## [155] 108.33333 109.30000 108.90000 109.30000 110.06667 110.70000 112.13333
## [162] 113.46667 114.90000 115.50000 116.53333 118.00000 119.66667 120.63333
## [169] 122.33333 124.10000 125.06667 126.46667 128.53333 129.83333 132.60000
## [176] 134.06667 135.00000 135.93333 137.06667 137.93333 139.13333 140.13333
## [183] 141.33333 142.16667 143.56667 144.33333 145.20000 145.93333 147.10000
## [190] 147.96667 149.30000 149.90000 151.40000 152.40000 153.26667 153.83333
## [197] 155.63333 156.76667 157.80000 158.76667 159.93333 160.30000 161.20000
## [204] 161.46667 162.20000 163.00000 163.66667 164.06667 165.23333 166.36667
## [211] 167.73333 168.46667 170.76667 172.23333 173.50000 174.40000 176.30000
## [218] 177.73333 177.83333 177.06667 178.80000 179.93333 181.00000 181.30000
## [225] 183.70000 183.70000 184.93333 184.66667 187.20000 189.40000 190.10000
## [232] 190.66667 193.23333 194.76667 198.13333 197.56667
cpi[,2]
##   [1]  21.5  21.9  21.9  21.9  22.0  22.2  22.5  23.0  23.0  23.1  23.4
##  [12]  23.7  23.5  23.4  23.8  23.9  24.1  24.4  24.5  24.5  24.4  24.2
##  [23]  24.1  24.0  23.8  23.8  23.9  23.8  23.9  23.7  23.8  23.9  23.7
##  [34]  23.8  23.6  23.5  23.5  23.6  23.6  23.7  23.8  24.1  24.3  24.4
##  [45]  24.6  24.7  25.0  25.4  25.7  25.8  25.8  25.9  25.9  25.9  25.9
##  [56]  26.1  26.2  26.4  26.5  26.5  26.3  26.3  26.4  26.4  26.5  26.7
##  [67]  26.7  26.7  26.7  26.7  26.7  26.6  26.5  26.6  26.6  26.7  26.8
##  [78]  26.8  26.9  26.9  27.0  26.9  26.9  26.9  26.9  26.9  26.8  26.9
##  [89]  26.9  26.9  26.9  26.8  26.8  26.8  26.7  26.7  26.7  26.7  26.7
## [100]  26.7  26.7  26.8  26.8  26.9  26.9  26.9  26.8  26.8  26.8  26.8
## [111]  26.9  27.0  27.2  27.4  27.3  27.4  27.5  27.5  27.6  27.6  27.7
## [122]  27.8  27.9  28.0  28.1  28.3  28.3  28.3  28.3  28.4  28.4  28.6
## [133]  28.6  28.8  28.9  28.9  28.9  29.0  28.9  28.9  28.9  29.0  28.9
## [144]  29.0  28.9  28.9  29.0  29.0  29.1  29.2  29.2  29.3  29.4  29.4
## [155]  29.4  29.3  29.4  29.4  29.5  29.5  29.6  29.6  29.6  29.6  29.8
## [166]  29.8  29.8  29.8  29.8  29.8  29.8  29.8  29.8  30.0  29.9  30.0
## [177]  30.0  30.0  30.0  30.0  30.1  30.1  30.2  30.2  30.2  30.3  30.3
## [188]  30.4  30.4  30.4  30.4  30.4  30.4  30.5  30.5  30.5  30.6  30.7
## [199]  30.7  30.7  30.8  30.8  30.9  30.9  30.9  30.9  30.9  30.9  31.0
## [210]  31.1  31.0  31.1  31.1  31.2  31.2  31.2  31.2  31.3  31.4  31.4
## [221]  31.6  31.6  31.6  31.6  31.7  31.7  31.8  31.8  32.0  32.1  32.3
## [232]  32.3  32.4  32.5  32.7  32.7  32.9  32.9  32.9  32.9  32.9  33.0
## [243]  33.1  33.2  33.3  33.4  33.5  33.6  33.7  33.8  33.9  34.1  34.2
## [254]  34.3  34.4  34.5  34.7  34.9  35.0  35.1  35.3  35.4  35.5  35.6
## [265]  35.8  36.1  36.3  36.4  36.6  36.8  37.0  37.1  37.3  37.5  37.7
## [276]  37.8  38.0  38.2  38.5  38.6  38.8  39.0  39.0  39.2  39.4  39.6
## [287]  39.8  39.8  39.9  40.0  40.1  40.3  40.6  40.7  40.8  40.8  40.9
## [298]  40.9  41.1  41.1  41.3  41.4  41.5  41.6  41.7  41.9  42.0  42.1
## [309]  42.3  42.4  42.5  42.6  42.9  43.3  43.6  43.9  44.2  44.3  45.1
## [320]  45.2  45.6  45.9  46.2  46.6  47.2  47.8  48.0  48.6  49.0  49.4
## [331]  50.0  50.6  51.1  51.5  51.9  52.1  52.5  52.7  52.9  53.2  53.6
## [342]  54.2  54.3  54.6  54.9  55.3  55.5  55.6  55.8  55.9  56.1  56.5
## [353]  56.8  57.1  57.4  57.6  57.9  58.0  58.2  58.5  59.1  59.5  60.0
## [364]  60.3  60.7  61.0  61.2  61.4  61.6  61.9  62.1  62.5  62.9  63.4
## [375]  63.9  64.5  65.2  65.7  66.0  66.5  67.1  67.4  67.7  68.3  69.1
## [386]  69.8  70.6  71.5  72.3  73.1  73.8  74.6  75.2  75.9  76.7  77.8
## [397]  78.9  80.1  81.0  81.8  82.7  82.7  83.3  84.0  84.8  85.5  86.3
## [408]  87.0  87.9  88.5  89.1  89.8  90.6  91.6  92.3  93.2  93.4  93.7
## [419]  94.0  94.3  94.6  94.5  94.9  95.8  97.0  97.5  97.7  97.9  98.2
## [430]  98.0  97.6  97.8  97.9  97.9  98.6  99.2  99.5  99.9 100.2 100.7
## [441] 101.0 101.2 101.3 101.9 102.4 102.6 103.1 103.4 103.7 104.1 104.5
## [452] 105.0 105.3 105.3 105.3 105.5 106.0 106.4 106.9 107.3 107.6 107.8
## [463] 108.0 108.3 108.7 109.0 109.3 109.6 109.3 108.8 108.6 108.9 109.5
## [474] 109.5 109.7 110.2 110.3 110.4 110.5 111.2 111.6 112.1 112.7 113.1
## [485] 113.5 113.8 114.4 115.0 115.3 115.4 115.4 115.7 116.0 116.5 117.1
## [496] 117.5 118.0 118.5 119.0 119.8 120.2 120.3 120.5 121.1 121.6 122.3
## [507] 123.1 123.8 124.1 124.4 124.6 125.0 125.6 125.9 126.1 127.4 128.0
## [518] 128.7 128.9 129.2 129.9 130.4 131.6 132.7 133.5 133.8 133.8 134.6
## [529] 134.8 135.0 135.2 135.6 136.0 136.2 136.6 137.2 137.4 137.8 137.9
## [540] 138.1 138.6 139.3 139.5 139.7 140.2 140.5 140.9 141.3 141.8 142.0
## [551] 141.9 142.6 143.1 143.6 144.0 144.2 144.4 144.4 144.8 145.1 145.7
## [562] 145.8 145.8 146.2 146.7 147.2 147.4 147.5 148.0 148.4 149.0 149.4
## [573] 149.5 149.7 149.7 150.3 150.9 151.4 151.9 152.2 152.5 152.5 152.9
## [584] 153.2 153.7 153.6 153.5 154.4 154.9 155.7 156.3 156.6 156.7 157.0
## [595] 157.3 157.8 158.3 158.6 158.6 159.1 159.6 160.0 160.2 160.1 160.3
## [606] 160.5 160.8 161.2 161.6 161.5 161.3 161.6 161.9 162.2 162.5 162.8
## [617] 163.0 163.2 163.4 163.6 164.0 164.0 163.9 164.3 164.5 165.0 166.2
## [628] 166.2 166.2 166.7 167.1 167.9 168.2 168.3 168.3 168.8 169.8 171.2
## [639] 171.3 171.5 172.4 172.8 172.8 173.7 174.0 174.1 174.0 175.1 175.8
## [650] 176.2 176.9 177.7 178.0 177.5 177.5 178.3 177.7 177.4 176.7 177.1
## [661] 177.8 178.8 179.8 179.8 179.9 180.1 180.7 181.0 181.3 181.3 180.9
## [672] 181.7 183.1 184.2 183.8 183.5 183.7 183.9 184.6 185.2 185.0 184.5
## [683] 184.3 185.2 186.2 187.4 188.0 189.1 189.7 189.4 189.5 189.9 190.9
## [694] 191.0 190.3 190.7 191.8 193.3 194.6 194.4 194.5 195.4 196.4 198.8
## [705] 199.2 197.6 196.8 198.3
cpi_q[length(cpi_q) + 1] <- cpi[length(cpi[,2]),2]

help(usgdp)

usgdp1 <- cbind(Nominal = usgdp,
               Inflation_Adjusted = usgdp/cpi_q)

autoplot(usgdp1, facet = TRUE)

For the usgdp data set, I found a data set of comsumer price index taken on the first day of the month every month from 1913-2018, then applied it to the graph to adjust for inflation.

autoplot(bricksq)

lambda2 <- BoxCox.lambda(bricksq)
autoplot(BoxCox(bricksq, lambda2))

For the bricksq data set, I applied a box cox transformation.

autoplot(enplanements)

help(enplanements)

enp1 <- cbind(Monthly = enplanements,
               DailyAverage = enplanements/monthdays(enplanements))

autoplot(enp1, facet = TRUE)

For the enplanements data, set I did a calendar adjustment to smooth out the graph from daily to monthly observations just as was done to the dole data set.