Assignment #9-forecasting

-Repeat the ts(), HoltWinters(), predict() and plot() functions on the Nile data as in these slides -Repeat the same functions with different values of alpha, beta, and gamma of your choosing on… AirPassengers EuStockMarkets When using the EuStockMarkets, choose one column

niledata <- data.frame(Nile)
niledata
##     Nile
## 1   1120
## 2   1160
## 3    963
## 4   1210
## 5   1160
## 6   1160
## 7    813
## 8   1230
## 9   1370
## 10  1140
## 11   995
## 12   935
## 13  1110
## 14   994
## 15  1020
## 16   960
## 17  1180
## 18   799
## 19   958
## 20  1140
## 21  1100
## 22  1210
## 23  1150
## 24  1250
## 25  1260
## 26  1220
## 27  1030
## 28  1100
## 29   774
## 30   840
## 31   874
## 32   694
## 33   940
## 34   833
## 35   701
## 36   916
## 37   692
## 38  1020
## 39  1050
## 40   969
## 41   831
## 42   726
## 43   456
## 44   824
## 45   702
## 46  1120
## 47  1100
## 48   832
## 49   764
## 50   821
## 51   768
## 52   845
## 53   864
## 54   862
## 55   698
## 56   845
## 57   744
## 58   796
## 59  1040
## 60   759
## 61   781
## 62   865
## 63   845
## 64   944
## 65   984
## 66   897
## 67   822
## 68  1010
## 69   771
## 70   676
## 71   649
## 72   846
## 73   812
## 74   742
## 75   801
## 76  1040
## 77   860
## 78   874
## 79   848
## 80   890
## 81   744
## 82   749
## 83   838
## 84  1050
## 85   918
## 86   986
## 87   797
## 88   923
## 89   975
## 90   815
## 91  1020
## 92   906
## 93   901
## 94  1170
## 95   912
## 96   746
## 97   919
## 98   718
## 99   714
## 100  740

Repeat the ts()

niledata.ts <- ts(niledata, start=1, frequency=10)
summary(niledata.ts)
##       Nile       
##  Min.   : 456.0  
##  1st Qu.: 798.5  
##  Median : 893.5  
##  Mean   : 919.4  
##  3rd Qu.:1032.5  
##  Max.   :1370.0

-Repeat HoltWinters()

niledata.hw1 <- HoltWinters(niledata.ts, gamma=FALSE)
niledata.hw1
## Holt-Winters exponential smoothing with trend and without seasonal component.
## 
## Call:
## HoltWinters(x = niledata.ts, gamma = FALSE)
## 
## Smoothing parameters:
##  alpha: 0.4190643
##  beta : 0.05987705
##  gamma: FALSE
## 
## Coefficients:
##         [,1]
## a 756.913740
## b  -7.424597

Repeat the predict()

niledata.pred <- predict(niledata.hw1, n.ahead = 10)

-Repeat the plot()

ts.plot(niledata.ts, niledata.pred)

-Repeat the same functions

with different values of alpha, beta, and gamma of your choosing on…

AirPassengers

air.passengers.ts <- ts(AirPassengers, start=1, frequency=10)
summary(air.passengers.ts)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   104.0   180.0   265.5   280.3   360.5   622.0
air.passengers.hw1 <- HoltWinters(air.passengers.ts, alpha = 0.7,beta = 0.7, gamma = 0.75)

air.passenger.pred <- predict(air.passengers.hw1, n.head=10)

plot

plot(air.passengers.ts)

plot(air.passengers.hw1)

ts.plot(air.passengers.ts, air.passenger.pred)

Stock Markets

euro.stock <- EuStockMarkets[,2]
euro.stock.ts <- ts(euro.stock, start=1, frequency=10)

-Repeat HoltWinters()

euro.stock.hw1 <- HoltWinters(euro.stock.ts, alpha = 0.5,beta = 0.3, gamma = 0.01)


summary(euro.stock.ts)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1587    2166    2796    3376    3812    8412
plot(euro.stock.ts)

plot(euro.stock.hw1)

euro.stock.p <- predict(euro.stock.hw1, n.ahead=10)
ts.plot(euro.stock.ts, euro.stock.p)