I am trying to fit the following hierarchical simplex factor analysis model
data {
int<lower=1> N;
int<lower=1> S;
int<lower=1> K;
int testmin;
int testmax;
int<lower=testmin, upper=testmax> P[S,N];
}
parameters {
simplex[K] W[N];
matrix[S,K] B0;
matrix[S,N] noise0;
ordered[testmax-1] c;
simplex[K] w0;
real<lower=0> alpha0;
real<lower=0> sigma;
real<lower=0> sigma_noise;
}
transformed parameters {
matrix[S,N] C;
matrix[S,N] noise;
matrix[S,K] B;
vector[K] alpha;
noise = sigma_noise*noise0;
B = sigma*B0;
for (n in 1:N)
C[,n] = B*W[n];
C += noise;
alpha = 1+alpha0*w0;
}
model {
//noise
sigma_noise ~ gamma(2.,10.);
to_vector(noise0) ~ normal(0,1);
//latent simplex representation
alpha0 ~ gamma(2.,10.);
w0 ~ dirichlet(rep_vector(2,K));
for (n in 1:N)
W[n] ~ dirichlet(alpha);
//basis vectors
sigma ~ gamma(2.,10.);
to_vector(B0) ~ normal(0,1);
//data generation (prior suggested by Carpenter on boards)
mean(c) ~ normal(0,1);
(c[2:(testmax-1)]-c[1:(testmax-2)]) ~ gamma(2.,10.);
for (n in 1:N) {
for (s in 1:S) {
P[s,n] ~ ordered_logistic(C[s,n], c);
}
}
}
The sampler actually works fairly well, but I am bit a bit baffled by some of the messages the sampler returns. I get several blocks of stuff like:
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: gamma_lpdf: Random variable[4] is -nan, but must not be nan! (in 'unknown file name' at line 54)
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: ordered_logistic: Cut points parameter is 2.76642e+66, but must be greater than 2.76642e+66 (in 'unknown file name' at line 57)
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: ordered_logistic: Cut points parameter is 704.671, but must be greater than 704.671 (in 'unknown file name' at line 57)
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: gamma_lpdf: Random variable[3] is -nan, but must not be nan! (in 'unknown file name' at line 54)
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: ordered_logistic: Cut points parameter is 20.2726, but must be greater than 20.2726 (in 'unknown file name' at line 57)
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: ordered_logistic: Cut points parameter is 4.19481e+75, but must be greater than 4.19481e+75 (in 'unknown file name' at line 57)
This occurs for different choices of cutpoint prior such as the normal and the uniform (the current one was suggested in another post) and initializations. Right now I am initializing each chain using the output of an optimizing call with 10 steps where I initialize the cutpoints to np.linspace(-1,1,testmax-1) (i.e. equally spaced grid in the [-1,1] interval).
I must be hitting some massive gradients to get proposal of that magnitude. Is my prior not adequately boundary-avoiding? Or is my initialization off? It seems like my sampler hits a stable regime after a while and the final output looks quite fine, but these reports have me worried.
P.S. A complete aside, but is there any way to make simplex factor models identifiable and avoid label switching?