-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nile_analysis_Navilli.R
56 lines (42 loc) · 1.16 KB
/
Nile_analysis_Navilli.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
rm(list=ls())
#import library forecast
library(forecast)
library(urca)
set.seed(42)
#import dataset Nile
data(Nile)
#Visualize infos about the TS
str(Nile.describe)
ggtsdisplay(Nile)
#hypothesis testing
summary(ur.kpss(Nile))
#checking the differencing degree
ndiffs(Nile)
#differencing
Nile.diff<-diff(Nile,1)
ggtsdisplay(Nile.diff)
#verifiy stationarity with hypothesis testing
summary(ur.kpss(Nile.diff))
#______________________________________________________________________________
#buid the models MA(1),AR(1),AR(2),ARMA(1,1)
ma1<-arima(Nile.diff, order=c(0,0,1), include.mean = FALSE)
ma1
autoplot(ma1)
checkresiduals(ma1)
autoplot(forecast(ma1,5))
ar1<-arima(Nile.diff, order=c(1,0,0), include.mean = FALSE)
ar1
autoplot(ar1)
checkresiduals(ar1)
autoplot(forecast(ar1,5))
ar2<-arima(Nile.diff, order=c(2,0,0), include.mean = FALSE)
ar2
autoplot(ar2)
checkresiduals(ar2)
autoplot(forecast(ar2,5))
arma11<-arima(Nile.diff, order=c(1,0,1), include.mean = FALSE)
arma11
autoplot(arma11)
checkresiduals(arma11)
autoplot(forecast(arma11,5))
#________________END MODEL SELECTION_________________________________________