kings <- scan("http://robjhyndman.com/tsdldata/misc/kings.dat",skip=3)
kings
##  [1] 60 43 67 50 56 42 50 65 68 43 65 34 47 34 49 41 13 35 53 56 16 43 69
## [24] 59 48 59 86 55 68 51 33 49 67 77 81 67 71 81 68 70 77 56
kingstimeseries <- ts(kings)
kingstimeseries
## Time Series:
## Start = 1 
## End = 42 
## Frequency = 1 
##  [1] 60 43 67 50 56 42 50 65 68 43 65 34 47 34 49 41 13 35 53 56 16 43 69
## [24] 59 48 59 86 55 68 51 33 49 67 77 81 67 71 81 68 70 77 56
plot.ts(kingstimeseries)
#install.packages("TTR")
#install.packages("forecast")
library(TTR)

library(forecast)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: timeDate
## This is forecast 7.3
kingstimeseriesSMA8 <- SMA(kingstimeseries,n=8)
plot.ts(kingstimeseriesSMA8)

fit <- HoltWinters(kingstimeseries, beta=FALSE, gamma=FALSE)
fit1<- ets(kingstimeseries)
forecast(fit, 3)
##    Point Forecast    Lo 80    Hi 80    Lo 95     Hi 95
## 43       67.79249 48.05162 87.53335 37.60144  97.98353
## 44       67.79249 47.35022 88.23475 36.52873  99.05624
## 45       67.79249 46.67209 88.91288 35.49163 100.09334
plot(forecast(fit, 3))

forecast(fit1, 3)
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 43       67.82931 48.61620 87.04241 38.44540 97.21322
## 44       67.82931 47.99645 87.66217 37.49756 98.16106
## 45       67.82931 47.39547 88.26314 36.57846 99.08016
plot(forecast(fit1, 3))