Ok now that I have solved the segfault issue by recompiling rstan (Segfault when using unit_vector and softmax), I can run the following model (A):
functions{
real vmf_lpdf(row_vector y, row_vector mu, real kappa);
}
data {
int<lower=0> N; //the number of observations
vector[N] X; //the model column vector of size N
matrix[N,3] y; //the multivariate response with N rows and 3 columns
}
parameters {
vector[2] theta_link;
real kappa_link;
unit_vector[3] mu_vec;
}
model {
real ps[2];
vector[2] theta;
theta_link ~ normal(0,2);
theta = softmax(theta_link);
for (n in 1:N) {
ps[1] = log(theta[1]) + vmf_lpdf(y[n] | mu_vec', exp(X[n]*kappa_link));
ps[2] = log(theta[2]) + log(1/(4*pi()));
target += log_sum_exp(ps);
}
}
but I am getting very different estimation results from just using a simplex as in this model (B):
functions{
real vmf_lpdf(row_vector y, row_vector mu, real kappa);
}
data {
int<lower=0> N; //the number of observations
vector[N] X; //the model column vector of size N
matrix[N,3] y; //the multivariate response with N rows and 3 columns
}
parameters {
simplex[2] theta;
real kappa_link;
unit_vector[3] mu_vec;
}
model {
real ps[2];
for (n in 1:N) {
ps[1] = log(theta[1]) + vmf_lpdf(y[n] | mu_vec', exp(X[n]*kappa_link));
ps[2] = log(theta[2]) + log(1/(4*pi()));
target += log_sum_exp(ps);
}
}
Model B with simplex gives better estimations. How can I change model A to give similar estimations as in B?