Skip to content

Commit cff0424

Browse files
committed
Create litter.stan
1 parent 089759a commit cff0424

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
data {
2+
int<lower=0> G;
3+
int<lower=0> N;
4+
int<lower=0> r[G,N];
5+
int<lower=0> n[G,N];
6+
}
7+
parameters {
8+
matrix<lower=0,upper=1>[G,N] p;
9+
vector<lower=0.1>[G] a;
10+
vector<lower=0.1>[G] b;
11+
}
12+
model {
13+
a ~ gamma(1,0.001);
14+
b ~ gamma(1,0.001);
15+
for (g in 1:G) {
16+
for (i in 1:N) {
17+
p[g,i] ~ beta(a[g],b[g]);
18+
r[g,i] ~ binomial(n[g,i],p[g,i]);
19+
}
20+
}
21+
}
22+
generated quantities {
23+
vector<lower=0,upper=1>[G] mu;
24+
vector<lower=0>[G] theta;
25+
for (g in 1:G)
26+
mu[g] <- a[g] / (a[g] + b[g]);
27+
for (g in 1:G)
28+
theta[g] <- 1 / (a[g] + b[g]);
29+
}

0 commit comments

Comments
 (0)