-
Notifications
You must be signed in to change notification settings - Fork 0
/
Investigate_power_nu_part.R
173 lines (111 loc) · 3.3 KB
/
Investigate_power_nu_part.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#=========================
# Investigate (d/rho)^nu
#=========================
# Reason:
# Matern function is a product of 3 parts:
# sigma2 * constant
# (d / rho)^nu
# K_v(d / rho) : done.
#--------
# Settings
#--------
image.path <- "./Image/"
d <- seq(0, 10, length.out = 100)
plot_Middle <- function(rho, nu) {
m <- (d / rho)^nu
plot(d, m, type = "l", main = paste0("rho: ", rho, "; nu:", nu),
cex = 0.5)
}
#----------------------------
# Plot for fixed rho and nu
#----------------------------
rho = 2
nu = 3/2
par(mfrow = c(1, 1), mar = c(3, 3, 3, 1))
plot_Middle(rho = rho, nu = nu)
#----------------------
# different rho and nu
#----------------------
png(paste0(image.path, "Middel_part_different_rho_nu.png"),
width = 8, height = 7, units = "in", res = 300)
Rho <- seq(0.5, 50, by = 10) # 0.5 10.5 20.5 30.5 40.5
Nu <- c(0.5, 1.5, 10, 50)
length(Rho) # [1] 5
length(Nu) # [1] 4
par(mfrow = c(5, 4), mar = c(2.5, 2.5, 2, 1))
for (rho in Rho) {
for (nu in Nu) {
plot_Middle(rho = rho, nu = nu)
}
}
dev.off()
#-----------
# Conclusions
#-----------
# large scale range parameter rho does not have significant effect
# on the values of the middel part
# when nu is small, the middel part is approximately linear
# when nu is large, the middel part becomes exponentially increase
# Q: when is the nu value that will drive a
# significant change to the shape of the middel part
# from approximate linear to exponentially increase?
#----------------------
# what nu value will change the middle part value from linear to expoential?
#----------------------
Rho <- seq(0.5, 50, by = 10) # 0.5 10.5 20.5 30.5 40.5
png(paste0(image.path, "Mid_part_nu_vs_line.png"),
width = 8, height = 7, units = "in", res = 300)
Nu <- seq(0.5, 10, by = 0.5)
length(Rho) # [1] 5
length(Nu) # [1] 20
par(mfrow = c(5, 4), mar = c(2, 1, 2, 1))
rho = 10
for (nu in Nu) {
plot_Middle(rho = rho, nu = nu)
abline(a = 0, b = 0.1, lty = 2, lwd = 0.5)
}
dev.off()
#----------
# Conclusion
#----------
# when nu in c(0.5, 1.5), the middle part curve
# approximates a linear line y = 0.1x
#-----------------------------------------
# Q: is c(0.5, 1.5) the ideal range for nu?
#-----------------------------------------
png(paste0(image.path, "nu_0.1-2_mse.png"),
width = 8, height = 7, units = "in", res = 300)
Nu <- seq(0.1, 2, by = 0.1)
length(Nu) # [1] 20
par(mfrow = c(5, 4), mar = c(2, 1, 2, 1))
plot_Middle_mse <- function(rho, nu) {
d <- seq(0, 10, length.out = 100)
M_vals <- (d / rho)^nu
L_vals <- 0.1 * d
MSE <- sum((M_vals - L_vals)^2) / length(d)
plot(d, M_vals, type = "l",
main = bquote(atop("nu:"~ .(nu),
atop("MSE:" ~ .(round(MSE, 2))))),
cex = 0.5)
abline(a = 0, b = 0.1, lty = 2, lwd = 0.5)
}
par(mfrow = c(4, 5), mar = c(2.3, 1, 3.5, 1), cex = 0.8)
for (nu in Nu) {
plot_Middle_mse(rho = 10, nu = nu)
}
dev.off()
#-----------
# Conclusion
#-----------
# When nu is with (0.7, 1.5), MSE is <= 0.1
# the middle part is approximately to a linear line
# of y = 0.1 x
rho = 10
nu = 0.1
d <- seq(0, 10, length.out = 100)
0.1 * d
M_vals <- (d / rho)^nu
L_vals <- 0.1 * d
sum((M_vals - L_vals)^2) / length(d)
par(mfrow = c(1, 1), mar = c(3, 3, 5, 1))
plot_Middle_mse(rho = 10, nu = 0.2)