It is just the bivariate normal distribution. But I got some error and I don’t know why :(
data {
int<lower=0> N;
matrix[N,2] X;
}
// The parameters accepted by the model. Our model
// accepts two parameters 'mu' and 'sigma'.
parameters {
real mu[2];
real<lower=0> sigma[2];
real<lower=-1, upper=1> rho;
}
transformed parameters{
matrix[2,2] S;
S[1,1] = sigma[1]^2;
S[2,2] = sigma[2]^2;
S[1,2] = sigma[1]*sigma[2]*rho;
S[2,1] = sigma[1]*sigma[2]*rho;
}
// The model to be estimated. We model the output
// 'y' to be normally distributed with mean 'mu'
// and standard deviation 'sigma'.
model {
//y ~ normal(mu, sigma);
mu[1] ~ normal(6.48,1);
mu[2] ~ normal(1.43,1);
sigma[1] ~ normal(1.85,1);
sigma[2] ~ normal(0.4,1);
rho ~ uniform(0,1);
for(i in 1:N){
X[i,] ~ multi_normal(mu,S);
}
}
Error is like this:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for:
row_vector ~ multi_normal(real[ ], matrix)
Available argument signatures for multi_normal:
vector ~ multi_normal(vector, matrix)
vector ~ multi_normal(vector[ ], matrix)
vector ~ multi_normal(row_vector, matrix)
vector ~ multi_normal(row_vector[ ], matrix)
vector[ ] ~ multi_normal(vector, matrix)
vector[ ] ~ multi_normal(vector[ ], matrix)
vector[ ] ~ multi_normal(row_vector, matrix)
vector[ ] ~ multi_normal(row_vector[ ], matrix)
row_vector ~ multi_normal(vector, matrix)
row_vector ~ multi_normal(vector[ ], matrix)
row_vector ~ multi_normal(row_vector, matrix)
row_vector ~ multi_normal(row_vector[ ], matrix)
row_vector[ ] ~ multi_normal(vector, matrix)
row_vector[ ] ~ multi_normal(vector[ ], matrix)
row_vector[ ] ~ multi_normal(row_vector, matrix)
row_vector[ ] ~ multi_normal(row_vector[ ], matrix)
Real return type required for probability function.
error in ‘model397588e61f4_Bivariate’ at line 45, column 29
43: rho ~ uniform(0,1);
44: for(i in 1:N){
45: X[i,] ~ multi_normal(mu,S);
^
46: }
Error in stanc(filename, allow_undefined = TRUE) :
failed to parse Stan model ‘Bivariate’ due to the above error.