/
Matern32Poisson_basicGP.stan
44 lines (36 loc) · 1.03 KB
/
Matern32Poisson_basicGP.stan
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
/*
* Matérn 3/2 GP with Poisson likelihood, basic implementation
* ------------------------------------------------------------
* Copyright: Juho Kokkala
* Date: 10 August 2016
* License: MIT
*/
data {
int<lower=0> N;
int<lower=0> y[N];
real<lower=0> dt; //Time between consecutive observations
}
parameters {
real mu; //Mean level of the log-intensity process
real<lower=0> lscale; //Lengthscale of the process
real<lower=0> stdev; //Standard deviation of the process
vector[N] x; //The log-intensity process
}
model {
vector[N] muvec;
matrix[N,N] Sigma;
for (i in 1:N) {
muvec[i] = mu;
}
for (i in 1:N) {
Sigma[i,i] = stdev*stdev;
for (j in 1:(i-1)) {
Sigma[i,j] = stdev*stdev * (1 + sqrt(3)*dt*(i-j)/lscale) * exp(-sqrt(3)*dt*(i-j)/lscale);
Sigma[j,i] = Sigma[i,j];
}
}
x ~ multi_normal(muvec,Sigma);
lscale ~ student_t(2,0,1);
stdev ~ student_t(2,0,1);
y ~ poisson_log(x);
}