I have a mixture model of a von Mises-Fisher distribution and a uniformly distributed spherical surface (\frac{1}{4\pi}) for noise. In the model below, I use theta to define the mixing proportion of these two components.
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);
}
}
The model above seems to work well. I want to extend the model such that theta is a function of X (similar to kappa_link above). I am not sure what is the best way to do it. In the model below, I tried to set theta as a function of X using an inv_logit function:
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 {
real theta_link;
real kappa_link;
unit_vector[3] mu_vec;
}
model {
real ps[2];
for (n in 1:N) {
ps[1] = log(inv_logit(X[n]*theta_link)) + vmf_lpdf(y[n] | mu_vec', exp(X[n]*kappa_link));
ps[2] = log(1-inv_logit(X[n]*theta_link)) + log(1/(4*pi()));
target += log_sum_exp(ps);
}
}
However, it is not giving stable results. Even when I removed X[n] from the link function, such that inv_logit(theta_link)
, I don’t get stable outcomes as in the first model above that uses simplex.
What is a good way to link theta to X? If there are any other problems with my model, please let me know too. Thank you!