-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdvals.R
59 lines (39 loc) · 1.97 KB
/
dvals.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
#env_path = '/home/bilgi/Desktop/lmts'
env_path = getwd()
setwd(env_path)
library(LongMemoryTS)
args = commandArgs(trailingOnly=TRUE)
file_name <- args[1]
print(file_name)
data <- read.csv(file_name)
get_d_values <- function(country) {
new_country <- country[!is.na(country)]
T <- length(new_country)
result_elw_m <- LongMemoryTS::ELW(data=new_country, m=floor(1+T^0.6),mean.est = "mean")$d
result_elw_n <- LongMemoryTS::ELW(data=new_country, m=floor(1+T^0.6),mean.est = "none")$d
result_elw2S_v0 <- LongMemoryTS::ELW2S(data=new_country, m=floor(1+T^0.6), trend_order=0, taper = "Velasco")$d
result_elw2S_v1 <- LongMemoryTS::ELW2S(data=new_country, m=floor(1+T^0.6), trend_order=1, taper = "Velasco")$d
result_elw2S_h0 <- LongMemoryTS::ELW2S(data=new_country, m=floor(1+T^0.6), trend_order=0, taper = "HC")$d
result_elw2S_h1 <- LongMemoryTS::ELW2S(data=new_country, m=floor(1+T^0.6), trend_order=1, taper = "HC")$d
result_gph <- LongMemoryTS::gph(X=new_country, m=floor(1+T^0.6), l=1)
result_hou_perron <- LongMemoryTS::Hou.Perron(data=new_country, m=floor(1+T^0.6))$d
result_local_w <- LongMemoryTS::local.W(data=new_country,int = c(-0.5, 2.5), m=floor(1+T^0.6), diff_param=1, taper = c("Velasco"),l=1)$d
result = data.frame(elw_m=result_elw_m,
elw_n=result_elw_n,
elw2s_v0=result_elw2S_v0,
elw2s_v1=result_elw2S_v1,
elw2s_h0 =result_elw2S_h0,
elw2s_h1 =result_elw2S_h1,
gph=result_gph,
hou_perron=result_hou_perron,
local_w = result_local_w)
return(result)
}
if (file_name =='ln_diff_wb.csv'){
data = subset(data, select = -c(FRO, LIE, DJI, TCA, SSD))
}
df_list<-lapply(data[2:length(data)],get_d_values)
d_values = do.call(what = rbind, args = df_list)
result_path = paste(env_path,'/data/app/d_values.csv',sep="")
print(result_path)
write.csv(d_values,result_path)