-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdir.stan
60 lines (55 loc) · 1.4 KB
/
dir.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
data {
int<lower=1> n;
int<lower=0> X[n, n];
// [[Additional data go here]]
}
parameters {
// [[Parameters go here]]
//
// For example:
// real<lower=0,upper=1> theta;
}
model {
// [[Priors go here]]
//
// For example:
// theta ~ beta(1, 1/2);
for (i in 1:n) {
for (j in 1:n) {
if (i != j) {
// [[Data model goes here]]
real log_mu_ij_0 = ;
real log_mu_ij_1 = ;
// [[Network model goes here]]
real log_nu_ij_0 = ;
real log_nu_ij_1 = ;
// Boilerplate code below, do not modify
real z_ij_0 = log_mu_ij_0 + log_nu_ij_0;
real z_ij_1 = log_mu_ij_1 + log_nu_ij_1;
if (z_ij_0 > z_ij_1) {target += z_ij_0 + log1p_exp(z_ij_1 - z_ij_0);}
else {target += z_ij_1 + log1p_exp(z_ij_0 - z_ij_1);}
}
}
}
}
generated quantities {
// Generate edge probability matrix
real Q[n ,n];
for (i in 1:n) {
Q[i, i] = 0;
for (j in 1:n) {
if (i != j) {
// [[Data model goes here, as in model block]]
real log_mu_ij_0 = ;
real log_mu_ij_1 = ;
// [[Network model goes here, as in model block]]
real log_nu_ij_0 = ;
real log_nu_ij_1 = ;
// Boilerplate code below, do not modify
real z_ij_0 = log_mu_ij_0 + log_nu_ij_0;
real z_ij_1 = log_mu_ij_1 + log_nu_ij_1;
Q[i, j] = 1 / (1 + exp(z_ij_0 - z_ij_1));
}
}
}
}