-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOMPSTAT_2018.Rmd
239 lines (181 loc) · 7.17 KB
/
COMPSTAT_2018.Rmd
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
---
title: "CircSpaceTime: An R package for spatial, spatio-temporal and temporal model for circular, cylindrical and spherical data"
author: |
|
| <a href="https://github.com/santoroma/CircSpaceTime">github.com/santoroma/CircSpaceTime</a></small>
| <small>23rd International Conference on Computational Statistics</small>
output:
revealjs::revealjs_presentation:
template: COMPSTAT_2018_Template.html
incremental: false
self_contained: false
reveal_plugins: ["notes", "zoom", "menu"]
theme: league
transition: zoom
background_transition: zoom
highlight: pygments
center: true
progress: true
slideNumber: true
menu:
numbers: true
defaultTiming: 120
---
# A brand new package {data-background="img/storm1.gif"}
## A brand new package {data-background="img/storm1.gif"}
- Currently the following models are implemented:
+ Spatial Wrapped Normal
+ Spatial Projected Normal
<br>
- Yet to come (in few weeks):
+ Spatio-Temporal Wrapped Normal
+ Spatio-Temporal Projected Normal
<br>
## A brand new package {data-background="img/inception_end.gif"}
- <span style="background-color:rgba(0,0,0,0.5)">Already available on GitHub at <a href="https://github.com/santoroma/CircSpaceTime">github.com/santoroma/CircSpaceTime</a>
The package will be released on CRAN before the end of the 2018.</span>
<br>
- <span style="background-color:rgba(0,0,0,0.5)">It will be constantly updated with Bayesian and classical models dealing with complex dependence structures for circular, cylindrical and spherical variable.</span>
<br>
# <span style="background-color:rgba(0,0,0,0.5)">A brief example</span> {data-background="img/map1.png"}
## {data-background="img/map1.png"}
- <span style="background-color:rgba(0,0,0,0.5)"> Example based on wave directions (and heights): a storm event observed at 8pm of April 6, 2010.</span>
<br>
<br>
- <span style="background-color:rgba(0,0,0,0.5)"> Data available inside the package.</span>
<br>
## Test data {data-background="img/plot2.png" data-background-size="100%" data-background-position="bottom"}
We hold out 10% of the locations for validation purposes
<br>
<br><br>
<br><br><br>
<br>
<br><br>
<br><br><br>
<br><br><br>
# Estimation based on the Wrapped Gaussian
## WrapSp
<small>
- **WrapSp** function produces samples from the Wrapped Normal spatial model posterior distribution
- As inputs it requires:
+ a vector of $n$ circular data in $[0,2\pi)$ and a matrix of coordinates (*train data* in our example)
+ two lists, one of starting values for the MCMC and the other for the prior distributions definition.
+ Further inputs are related to computational options such as the number of chains, if the computation should be parallelized and the number of iterations.
```{r wrapsp, warning = FALSE, echo=TRUE, eval=FALSE, size="tiny"}
storm <- WrapSp(
x = train0$Dmr,
coords = coords0.train,
start = start0 ,
prior = list("alpha" = c(pi,10),
"rho" = c(rho_min0, rho_max0),
"sigma2" = c(3,0.5),
"beta" = c(1,1,2)
) ,
nugget = TRUE,
sd_prop = list( "sigma2" = 1, "rho" = 0.3, "beta" = 1),
iter = 30000,
bigSim = c(burnin = 15000, thin = 10),
accept_ratio = 0.5,
adapt_param = c(start = 1000, end = 10000, esponente = 0.95),
corr_fun = "exponential",
n_chains = 2,
parallel = T,
n_cores = 2)
```
</small>
## WrapKrig
<small>
- **WrapKrig** function estimate the values on the test sites using the posterior samples we just obtained
- As inputs it requires:
+ the output of *WrapSp*
+ the coordinates for the train (observed) points
+ the coordinates of the test (validation) points
+ the observed (train) circular values
</small>
```{r wrapkrig, warning = FALSE, echo=TRUE, eval=FALSE}
Pred.storm <- WrapKrig(
WrapSp_out = storm,
## The coordinates for the observed points
coords_obs = coords0.train,
## The coordinates of the validation points
coords_nobs = coords0.test,
##the observed circular values
x_oss = train0$Dmr
)
```
# Estimation based on the Projected Gaussian
## ProjSp
<small>
- **ProjSp** function produces samples from the Projected Normal spatial model posterior distribution
- As inputs it requires:
+ a vector of $n$ circular data in $[0,2\pi)$ and a matrix of coordinates (*train data* in our example)
+ two lists, one of starting values for the MCMC and the other for the prior distributions definition.
+ Further inputs are related to computational options such as the number of chains, if the computation should be parallelized and the number of iterations.
```{r projsp, warning = FALSE, echo=TRUE, eval=FALSE, size="tiny"}
mod0_PN <- ProjSp(
x = train0$Dmr,
coords = coords0.train,
start = start0_PN ,
prior = list("alpha_mu" = c(0,0),
"alpha_sigma" = diag(10,2),
"rho0" = c(rho_min0, rho_max0),
"rho" = c(-1,1),
"sigma2" = c(3,0.5)),
sd_prop = list( "sigma2" = .1, "rho0" = 0.1, "rho" = .1, "sdr" = sample(.05,length(train0$Dmr), replace = T)),
iter = 5000,
bigSim = c(burnin = 3500, thin = 1),
accept_ratio = 0.5,
adapt_param = c(start = 1000, end = 10000, esponente = 0.95, sdr_update_iter = 50),
corr_fun = "exponential",
n_chains = 2,
parallel = T,
n_cores = 2)
```
</small>
## ProjKrig
<small>
- **ProjKrig** function estimate the values on the test sites using the posterior samples we just obtained
- As inputs it requires:
+ the output of *ProjSp*
+ the coordinates for the train (observed) points
+ the coordinates of the test (validation) points
+ the observed (train) circular values
</small>
```{r projkrig, warning = FALSE, echo=TRUE, eval=FALSE}
Pred.krig_PN <- ProjKrig(mod0_PN,
## The coordinates for the observed points
coords_obs = coords0.train,
## The coordinates of the validation points
coords_nobs = coords0.test,
##the observed circular values
x_oss = train0$Dmr)
```
## Comparison
- We can compare the predictions of the two models using the Average Prediction Error (APE)
<br>
- It's the package function **APEcirc**
<br>
<br>
<br>
```{r print_APE_comparison, echo=FALSE, message=FALSE, warnings=FALSE, results='asis'}
tabl <- "
| | Wrapped | Projected |
|---------------------------|:-------:|----------:|
| Average Prediction Error | 0.0007 | 0.0010 |
"
cat(tabl)
```
```{r ape, warning = FALSE, echo=TRUE, eval=FALSE, size="tiny"}
APE_WRAP <- APEcirc( real = test0$Dmr,
sim = Pred.storm$Prev_out,
bycol = F
)
APE_PN <- APEcirc( real = test0$Dmr,
sim = Pred.krig_PN$Prev_out,
bycol = F
)
```
# ... this is the END {data-background="img/truman_show_end.gif"}
## THANKS!!! {data-background="img/truman_show_end.gif"}
Further information and installation instructions on
<span style="background-color:rgba(0,0,0,0.6)"><font size="+14">[github.com/santoroma/CircSpaceTime](https://github.com/santoroma/CircSpaceTime)</font></span>