-
Notifications
You must be signed in to change notification settings - Fork 0
/
finalcode.r
74 lines (71 loc) · 1.64 KB
/
finalcode.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#library('ggplot2')
library('forecast')
library('tseries')
#library('tidyverse')
library('TTR')
data<-read.csv("C:/COLLEGE/PROJECT/dat1.csv")
print(data)
#data1<-ts(data)
#print(data1)
plot(data$total,type="o")
adf=adf.test(data$total)
print(adf)
acf(data$total)
dyield=diff(data$total)
plot(dyield,type="o")
acf(dyield)
adf1=adf.test(dyield)
print(adf1)
pacf(dyield)
model<-arima(data$total,order = c(4,1,2),method = "ML")
print(model)
print(BIC(model))
fore<-forecast(model,h=3)
print(fore)
plot(fore)
model3<-arima(data$total,order = c(4,1,3))
print(model3)
print(BIC(model3))
fore3<-forecast(model3,h=3)
print(fore3)
plot(fore3)
model1<-arima(data$total,order = c(5,1,2))
print(model1)
print(BIC(model1))
fore1<-forecast(model1,h=3)
print(fore1)
plot(fore1)
model2<-arima(data$total,order = c(5,1,3))
print(model2)
print(BIC(model2))
fore2<-forecast(model2,h=3)
print(fore2)
plot(fore2)
model4<-arima(data$total,order = c(4,1,1))
print(model4)
print(BIC(model4))
fore4<-forecast(model4,h=3)
print(fore4)
plot(fore4)
print(model$residuals)
print(Box.test(model$residuals,type = "Ljung-Box"))
print(Box.test(model1$residuals,type = "Ljung-Box"))
print(Box.test(model2$residuals,type = "Ljung-Box"))
print(Box.test(model3$residuals,type = "Ljung-Box"))
print(Box.test(model4$residuals,type = "Ljung-Box"))
auto<-auto.arima(data$total,allowdrift=FALSE)
print(auto)
fore<-forecast(auto,h=3)
print(fore)
plot(fore)
accuracy(model)
accuracy(model3)
accuracy(model1)
accuracy(model2)
accuracy(model4)
accuracy(auto)
decomdata<-decompose(data$total)
plot(decomdata)
datas<-stl(data1)
datas
reg=lm(data)