-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstationarity.R
71 lines (48 loc) · 1.3 KB
/
stationarity.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
install.packages("readxl")
require(readxl)
install.packages("fUnitRoots")
require(fUnitRoots)
install.packages("MTS")
require(MTS)
da = read_excel("sp500_data.xlsx")
dim(da)
head(da)
com_ = da[,2]
con_ = da[,3]
fin_ = da[,4]
inf_ = da[,5]
com = log(na.omit(as.numeric(unlist(com_[[1]]))))
con = log(na.omit(as.numeric(unlist(con_[[1]]))))
fin = log(na.omit(as.numeric(unlist(fin_[[1]]))))
inf = log(na.omit(as.numeric(unlist(inf_[[1]]))))
z = cbind(com, con, fin, inf)
zt = diffM(log(z,2))
apply(zt, 8, adfTest)
m1=ar(diff(com),method = "mle")
m1$order
adfTest(com,lags=8)
adfTest(com,lags=8,type="c")
adfTest(com,lags=8,type="ct")
library(urca) ### Load urca package
urppTest(com) ## Phillips and Perron test
m2=ar(diff(con),method="mle")
m2$order
adfTest(con,lags=3)
adfTest(con,lags=3,type="c")
adfTest(con,lags=3,type="ct")
library(urca) ### Load urca package
urppTest(con) ## Phillips and Perron test
m3=ar(diff(fin),method="mle")
m3$order
adfTest(con,lags=0)
adfTest(con,lags=0,type="c")
adfTest(con,lags=0,type="ct")
library(urca) ### Load urca package
urppTest(fin) ## Phillips and Perron test
m4=ar(diff(inf),method="mle")
m4$order
adfTest(con,lags=8)
adfTest(con,lags=8,type="c")
adfTest(con,lags=8,type="ct")
library(urca) ### Load urca package
urppTest(inf) ## Phillips and Perron test