-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccc stocks.r
51 lines (41 loc) · 1.42 KB
/
ccc stocks.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
mat <- read.csv(file="I:/New Project/Stocks/akcie_diff.csv",head=TRUE,sep=",")
library(tseries)
p1 = mat[,1]
p2 = mat[,2]
p3 = mat[,3]
p4 = mat[,4]
p5 = mat[,5]
p6 = mat[,6]
p = cbind(p1,p2,p3,p4,p5,p6)
y = p
y[,1] = y[,1]-mean(y[,1])
y[,2] = y[,2]-mean(y[,2])
y[,3] = y[,3]-mean(y[,3])
y[,4] = y[,4]-mean(y[,4])
y[,5] = y[,5]-mean(y[,5])
y[,6] = y[,6]-mean(y[,6])
T = length(y[,1])
library(ccgarch)
library(fGarch)
f1 = garchFit(~ garch(1,1), data=y[,1],include.mean=FALSE)
f1 = f1@fit$coef
f2 = garchFit(~ garch(1,1), data=y[,2],include.mean=FALSE)
f2 = f2@fit$coef
f3 = garchFit(~ garch(1,1), data=y[,3],include.mean=FALSE)
f3 = f3@fit$coef
f4 = garchFit(~ garch(1,1), data=y[,4],include.mean=FALSE)
f4 = f4@fit$coef
f5 = garchFit(~ garch(1,1), data=y[,5],include.mean=FALSE)
f5 = f5@fit$coef
f6 = garchFit(~ garch(1,1), data=y[,6],include.mean=FALSE)
f6 = f6@fit$coef
a = c(f1[1],f2[1],f3[1],f4[1],f5[1],f6[1])
A = diag(c(f1[2],f2[2],f3[2],f4[2],f5[2],f6[2]))
B = diag(c(f1[3],f2[3],f3[3],f4[3],f5[3],f6[3]))
cccpara = diag(c(1,1,1,1,1,1))
cccresults = eccc.estimation(a=a, A=A, B=B, R=cccpara ,dvar=y, model="diagonal")
cccresults$out
A=cccresults$out
B=cccresults$h
write.table(A,file="I:/New Project/Stocks/ccc_stocks_final.csv",sep = ",",col.names = NA,qmethod = "double")
write.table(B,file="I:/New Project/Stocks/ccc_stocks_variance_diag.csv",sep = ",",col.names = NA,qmethod = "double")