-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.r
98 lines (55 loc) · 1.38 KB
/
Code.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#Load Libraries
library(readxl)
library(AER)
library(tseries)
library(dynlm)
library(strucchange)
library(stats)
library(zoo)
library(ggplot2)
library(dplyr)
#Load The Data
Data <- read.csv('.../Central Bank of Sudan Balance Sheet.csv')
Data <- subset(Data, select = c(-1))
Data <- Data[,1:12]
View(Data)
#Basic Statistics
summary(Data)
var(Data)
#Data That I Will Work On It
Use <- data.frame(rowSums(Data))
use <- ts(Use, start = 2012, frequency = 1)
View(use)
#Plot The Data
plot(use)
#Test The Data
acf(diff(diff(use)), plot = FALSE)
pacf(diff(use), plot = FALSE)
use_par <- expand.grid(ar = 0:2, diff = 1, ma = 0:2, sar = 0:1, sdiff = 1, sma = 0:1)
use_aic <- rep(0, nrow(use_par))
for (i in seq(along = use_aic))
use_aic[i] <- AIC(arima(use, unlist(use_par[i, 1:3]), unlist(use_par[i, 4:6])), k = log(length(use)))
use_par[which.min(use_aic),]
#ARIMA Model
use_arima <- arima(use, order = c(1, 1, 0), seasonal = c(0, 1, 0))
use_arima
tsdiag(use_arima)
#Prediction
use_pre <- predict(use_arima, n.ahead = 18*4)
#Unit Root Test
adf.test(use)
adf.test(log(use))
adf.test(diff(log(use)), k=0)
pp.test(diff(log(use)))
#Stationary Test
kpss.test(diff(log(use)))
#Cointegration Test
po.test(log(use))
#The Model
Model <- dynlm(use ~ L(use) + L(use, 4), data = use)
summary(Model)
#Heteroscedasticity Test
bptest(Model)
#Serialcorrelation
bgtest(Model)
dwtest(Model)