-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis_of_gapped_series.R
71 lines (65 loc) · 1.6 KB
/
analysis_of_gapped_series.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
library(ggplot2)
library(reshape2)
normalize_values = function(x,min,max) {
return((x - min)/(max-min))
}
# How do the metrics perform when measuring gapped series
crmse = c()
pear = c()
spear = c()
manh = c()
eucl = c()
x_series_vector = c()
y_series_vector = c()
ntries = 1000
j = 0
for (i in seq(1,ntries)) {
x = c(5,6,7,8,9,10)
y = c(5,6,7,8,9,10)
x_y = rbind(x, y)
pear = c(pear, cor(y, x, method='pearson'))
spear = c(spear, cor(y, x, method='spearman'))
manh = c(manh,dist(x_y, method = "manhattan"))
eucl = c(eucl,dist(x_y, method = "euclidean"))
y_series = y - mean(y)
x_series = x - mean(x)
crmse = c(crmse, sqrt(sum((y_series - x_series)**2)/length(x)))
x_series_vector = c(x_series_vector, x_series)
y_series_vector = c(y_series_vector, y_series)
j = j + 1
}
plot(crmse)
plot(pear)
plot(spear)
plot(manh)
plot(eucl)
# How do the metrics perform when measuring gapped series where only one is gapped.
crmse = c()
pear = c()
spear = c()
manh = c()
eucl = c()
x_series_vector = c()
y_series_vector = c()
ntries = 1000
j = 0
for (i in seq(1,ntries)) {
x = c(5,6,7,10,11,12)
y = c(5,6,7,8,9,10)
x_y = rbind(x, y)
pear = c(pear, cor(y, x, method='pearson'))
spear = c(spear, cor(y, x, method='spearman'))
manh = c(manh,dist(x_y, method = "manhattan"))
eucl = c(eucl,dist(x_y, method = "euclidean"))
y_series = y - mean(y)
x_series = x - mean(x)
crmse = c(crmse, sqrt(sum((y_series - x_series)**2)/length(x)))
x_series_vector = c(x_series_vector, x_series)
y_series_vector = c(y_series_vector, y_series)
j = j + 1
}
plot(crmse)
plot(pear)
plot(spear)
plot(manh)
plot(eucl)