-
Notifications
You must be signed in to change notification settings - Fork 0
/
CEMDANFortnight.R
100 lines (45 loc) · 1.64 KB
/
CEMDANFortnight.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
98
99
100
w<-read.csv("G:\\Gazvin\\CEEMDAN\\fortnightce.csv",header=TRUE)
class(w)
A <- as.ts(w)
A
library(Rlibeemd)
#########################CEEMDAN###################################
#Local Extrema of Time Series
ext <- extrema(A)
plot(A, ylim = range(ext$maxima[, 2], ext$minima[, 2]), main="Local Extrema of fortnight Time series")
points(ext$maxima, col = 2, pch = 19)
points(ext$minima, col = 2, pch = 19)
imfs <- ceemdan(A, threads = 1)
View(imfs)
#########for finding lags for IMFs
x<-as.matrix(imfs)
nst=1;n=2693;y=rep(0,n);c=10
d<- (x[,c])
acf(d)
pacf(d)
########EXPORTING DATA####
install.packages("openxlsx")
library(openxlsx)
write.xlsx(imfs, "fortnightceresults.xlsx")
#pacf baraye output ma lag hara moshakhas mikonad
#ccf ham ba tavajoh b dadehaye vorodi, lag haye input ha ra moshakhas mikonad baraye ma
#dar inja man debi dadeh vorodi and rosob dadeh khoroji man bod
IMF1<- imfs[,1]
acf(IMF1)
pacf(IMF1)
Res<- imfs[,9]
acf(Res)
pacf(Res)
##############################################
# trend extraction
ts.plot(A, imfs[, ncol(imfs)], col = 1:2,
main = "t", ylab = "streamflow")
# CEEMDAN for logarithmic demand, note that increasing ensemble size
# will produce smoother results
imfs <- ceemdan(log(A), ensemble_size = 50, threads = 1)
plot(ts.union("log(obs)" = log(A), Seasonal = imfs[, 1],
Irregular = rowSums(imfs[, 2:5]), Trend = imfs[, 6]),
main = "Streamflow")
################For Modelling#############
install.packages("seer")
browseURL("https://github.com/thiyangt/seer")