-
Notifications
You must be signed in to change notification settings - Fork 1
/
gpl-stan-models.R
30 lines (28 loc) · 958 Bytes
/
gpl-stan-models.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
##################################################################
## Davidson model for paired comparisons
## author: [email protected]
Davidson_code = '
data {
int<lower=1> K; // number of entities
int<lower=1> n; // number of observations (paired comparisons)
int<lower=0> y[n,2]; // paired comparisons
int<lower=0,upper=1> t[n,1]; // ties indicator
real<lower=0> a; // gamma prior parameter for lambda
real<lower=0> b; // gamma prior parameter for lambda
real<lower=0> c; // gamma prior parameter for delta
real<lower=0> d; // gamma prior parameter for delta
}
parameters {
real<lower=0> lambda[K];
real<lower=0> delta;
}
model {
real drll;
lambda ~ gamma(a,b);
delta ~ gamma(c,d);
for(i in 1:n){
drll = delta*sqrt(lambda[y[i,1]]*lambda[y[i,2]]);
target += (1-t[i,1])*log(lambda[y[i,1]])+t[i,1]*log(drll)-log(lambda[y[i,1]]+lambda[y[i,2]]+drll);
}
}
'