forked from avehtari/BDA_R_demos
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrp_prior_mean_var.stan
More file actions
25 lines (25 loc) · 955 Bytes
/
Copy pathgrp_prior_mean_var.stan
File metadata and controls
25 lines (25 loc) · 955 Bytes
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
// Comparison of k groups with unequal variance and
// hierarchical priors for the mean and the variance
data {
int<lower=0> N; // number of data points
int<lower=0> K; // number of groups
int<lower=1,upper=K> x[N]; // group indicator
vector[N] y; //
}
parameters {
real mu0; // prior mean
real<lower=0> musigma0; // prior std
vector[K] mu; // group means
real lsigma0; // prior mean
real<lower=0> lsigma0s; // prior std
vector<lower=0>[K] sigma; // group stds
}
model {
mu0 ~ normal(10, 10); // weakly informative prior
musigma0 ~ cauchy(0,10); // weakly informative prior
mu ~ normal(mu0, musigma0); // population prior with unknown parameters
lsigma0 ~ normal(0,1); // weakly informative prior
lsigma0s ~ normal(0,1); // weakly informative prior
sigma ~ cauchy(lsigma0, lsigma0s); // population prior with unknown parameters
y ~ normal(mu[x], sigma[x]);
}