Skip to content

Commit 4c3cbce

Browse files
author
Andrew Johnson
committed
Initial update
1 parent 5dcadbc commit 4c3cbce

13 files changed

+153
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
data {
2+
int<lower=0> N;
3+
int<lower=0, upper=1> y[N];
4+
}
5+
parameters {
6+
real<lower=0, upper=1> theta;
7+
}
8+
model {
9+
theta ~ beta(1, 1);
10+
y ~ bernoulli(theta);
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
data {
2+
int<lower=1> N;
3+
int<lower=0> y[N];
4+
}
5+
parameters {
6+
real<lower=0> alpha;
7+
real<lower=0, upper=1> p_success;
8+
}
9+
transformed parameters {
10+
real<lower=0.0> beta = p_success / (1.0 - p_success);
11+
}
12+
model {
13+
y ~ neg_binomial(alpha, beta);
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
data {
2+
int<lower=1> N;
3+
int<lower=0> y[N];
4+
}
5+
parameters {
6+
real<lower=0> alpha;
7+
real<lower=0> beta;
8+
}
9+
model {
10+
alpha ~ cauchy(0, 10);
11+
beta ~ cauchy(0, 10);
12+
y ~ neg_binomial(alpha, beta);
13+
}

basic_estimators/normal_censored

1.57 MB
Binary file not shown.
1.57 MB
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
data {
2+
real U;
3+
int<lower=0> N_censored;
4+
int<lower=0> N_observed;
5+
real<upper=U> y[N_observed];
6+
}
7+
parameters {
8+
real mu;
9+
}
10+
model {
11+
// Vectorization with truncation is not yet supported
12+
for (n in 1:N_observed)
13+
y[n] ~ normal(mu,1.0) T[,U];
14+
target += N_censored * normal_lccdf(U | mu, 1);
15+
}
16+
17+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
transformed data {
2+
vector[5] y = [2, 1, -0.5, 3, 0.25]';
3+
}
4+
parameters {
5+
real mu;
6+
}
7+
model {
8+
y ~ normal(mu, 1);
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data {
2+
int<lower=1> K;
3+
int<lower=1> N;
4+
vector[N] y;
5+
}
6+
parameters {
7+
simplex[K] theta;
8+
vector[K] mu;
9+
vector<lower=0, upper=10>[K] sigma;
10+
}
11+
model {
12+
vector[K] ps[N];
13+
mu ~ normal(0,10);
14+
for (n in 1:N) {
15+
for (k in 1:K) {
16+
ps[n][k] = normal_log(y[n] | mu[k], sigma[k]);
17+
}
18+
}
19+
target += log_mix(theta, ps);
20+
}
1.7 MB
Binary file not shown.
1.71 MB
Binary file not shown.

0 commit comments

Comments
 (0)