39. Stanで計算してみる
8つの学校の結果の分布
学校
効果の
平均 標準偏差
A 28 15
B 8 10
C -3 16
D 7 11
E -1 9
F 1 11
G 18 10
H 12 18
8つの学校に対して、あるテスト対策を講じた際の効果
のデータ。これをモデル化して推定する。
ex) 8-school
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#example-1-eight-schools
41. Stanで計算してみる
data {
int<lower=0> J; // number of schools
real y[J]; //
real<lower=0> sigma[J]; // s.e. of effect estimates
} parameters {
real mu;
real<lower=0> tau;
real eta[J];
} transformed parameters {
real theta[J];
for (j in 1:J)
theta[j] <- mu + tau * eta[j];
} model {
eta ~ normal(0, 1);
y ~ normal(theta, sigma);
}
Stanコード