Fa Assignment
Fa Assignment
csv")
datawide <- ts(mody, frequency=4, start=c(1983,1))
library("TTR")
plot.ts(datawide)
> datawide
Qtr1 Qtr2 Qtr3 Qtr4
1983 80.20 71.21 48.26 51.25
1984 60.10 67.55 63.54 60.28
1985 54.80 55.41 63.56 74.04
1986 71.16 87.24 111.11 105.90
1987 97.99 110.45 112.61 126.97
It looks like a multiplicative model since the size of the seasonal fluctuations and random fluctuations
seem to increase with the level of the time series. Also, the random fluctuations in the data are not
roughly constant in size over time.
acf(datawide, lag.max=20)
> pacf(datawide, lag.max=20)
So, this is a AR(1) model with negative phi.
> r1<-arima(ats,order=c(1,0,0),method="ML")
> predict(r1,n.ahead=1)
$pred
Qtr1
1954 123.9675
$se
Qtr1
1954 10.70735
Call:
HoltWinters(x = ats, alpha = TRUE, beta = TRUE, gamma = TRUE)
Smoothing parameters:
alpha: TRUE
beta : TRUE
gamma: TRUE
Coefficients:
[,1]
a 130.281563
b 8.400000
s1 4.085938
s2 8.497187
s3 -9.271562
s4 -3.311563
> summary(atsHWfit)
Length Class Mode
fitted 64 mts numeric
x 20 ts numeric
alpha 1 -none- logical
beta 1 -none- logical
gamma 1 -none- logical
coefficients 6 -none- numeric
seasonal 1 -none- character
SSE 1 -none- numeric
call 5 -none- call
>
> # For pedicting future value
> predict(atsHWfit,n.ahead=4 )
Qtr1 Qtr2 Qtr3 Qtr4
1954 142.7675 155.5788 146.2100 160.5700
>
> # Confidence intervals
> lhwl <- (forecast(atsHWfit, h=12)$lower)[,2]
> uhwl <- (forecast(atsHWfit, h=12)$upper)[,2]
>
> # Combining the limits and predicted value
> cbind(forecast(atsHWfit, h=12)$mean, lhwl, uhwl)
forecast(atsHWfit, h = 12)$mean lhwl uhwl
1954 Q1 142.7675 99.43546 186.0995
1954 Q2 155.5788 58.68536 252.4721
1954 Q3 146.2100 -15.92364 308.3436
1954 Q4 160.5700 -76.76935 397.9094
1955 Q1 176.3675 -144.99150 497.7265
1955 Q2 189.1788 -224.18256 602.5401
1955 Q3 179.8100 -332.90160 692.5216
1955 Q4 194.1700 -424.73531 813.0753
1956 Q1 209.9675 -521.56152 941.4965
1956 Q2 222.7788 -627.45726 1073.0148
1956 Q3 213.4100 -761.32012 1188.1401
1956 Q4 227.7700 -876.98457 1332.5246
>
> decots$trend
Qtr1 Qtr2 Qtr3 Qtr4
1949 NA NA 60.21750 57.24750
1950 58.70000 61.73875 62.20500 60.02500
1951 58.51000 60.23250 63.99750 70.02125
1952 79.94375 89.87000 97.20625 103.46125
1953 106.55000 109.37125 NA NA
> decots$random
Qtr1 Qtr2 Qtr3 Qtr4
1949 NA NA -13.7095312 -7.2173437
1950 5.2723438 4.9107812 -0.4170313 -0.9648438
1951 0.1623437 -5.7229687 -2.1895313 2.7989063
1952 -4.9114062 -3.5304688 12.1517188 1.2189062
1953 -4.6876563 0.1782812 NA NA
> plot(decots)