Skip to content

Instantly share code, notes, and snippets.

@kosugitti
Created October 17, 2016 00:58
Show Gist options
  • Save kosugitti/8ed2ca739511f034d5dad899846e1204 to your computer and use it in GitHub Desktop.
Save kosugitti/8ed2ca739511f034d5dad899846e1204 to your computer and use it in GitHub Desktop.
data{
int<lower=0> N;
vector[3] X[N];
}
parameters{
vector[3] mu;
real<lower=0> sig[3];
real<lower=-1,upper=1> rho;
}
transformed parameters{
cov_matrix[3] Sigma;
Sigma[1,1] = sig[1]*sig[1];
Sigma[2,2] = sig[2]*sig[2];
Sigma[3,3] = sig[3]*sig[3];
Sigma[1,2] = sig[1]*sig[2]*rho;
Sigma[1,3] = sig[1]*sig[3]*rho;
Sigma[2,3] = sig[2]*sig[3]*rho;
Sigma[2,1] = Sigma[1,2];
Sigma[3,1] = Sigma[1,3];
Sigma[3,2] = Sigma[2,3];
}
model{
X ~ multi_normal(mu,Sigma);
mu ~ normal(60,100);
rho ~ uniform(-1,1);
sig ~ cauchy(0,2.5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment