-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpnbd.stan
41 lines (34 loc) · 903 Bytes
/
pnbd.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
//Copyright 2018 Aaron Goodman <[email protected]>. Licensed under the GPLv3 or later.
#include /pnbd_data.stan
parameters{
real log_r;
real log_alpha;
real log_s;
real log_beta;
vector[NC] log_lambda;
vector[NC] log_mu;
}
transformed parameters{
vector[NC] likelihood;
real r = exp(log_r);
real alpha = exp(log_alpha);
real s = exp(log_s);
real beta = exp(log_beta);
vector[NC] lambdamu = exp(log_lambda) + exp(log_mu);
#include /pnbdlikelihoodloop.stan
}
model{
target += NC*(r * log_alpha - lgamma(r));
target += r*log_lambda - alpha*exp(log_lambda);
target += NC*(s * log_beta - lgamma(s));
target += s*log_mu - beta*exp(log_mu);
target += log_r + log_alpha + log_s + log_beta;
r ~ normal(1,1);
alpha ~ normal(1,1);
s ~ normal(1,1);
beta ~ normal(1,1);
target += likelihood;
}
generated quantities{
#include /pnbd_generatedquantities.stan
}