This seems very similar to an issue from another post, as the issue of the latent factor theta indeterminancy. Meaning that at any given iteration the factor can be in a positive of negative direction, for example would mean “High Fatigue” or “Low Fatigue”.
https://discourse.mc-stan.org/t/non-convergence-of-latent-variable-model/12450/15
The solution that I suggested was to estimate the factor loadings without constraint, and adjust the direction of the factor in function of 1 item, in the generated quantities block.
Here I am “fixing” the factor loading for item 1 in category 1 to be negative. So, if the iteration gives a positive value to this factor loading, the code will multiply all the factor loadings and latent factor for -1. So, lambdan_swt and theta_swt go in the direction that I wanted.
I ran your code, with this new block, and it converged with 5000 iterations
generated quantities{
vector[K] lambdan_swt[n_item]; // sign adjusted lambda
vector[n_student] theta_swt; // latent trait
lambdan_swt = lambdan;
theta_swt = theta;
if(lambdan[1,1] > 0){
for (i in 1:K){
for (j in 1:n_item){
lambdan_swt[j,i] = -1*lambdan[j,i]; }}
theta_swt = -1*theta;
}
}
Notice that I did this in function of the center factor loadings. Since I am not familiar with this model, I dont know if it would work with the uncenter ones, or which ones are the “right ones” to use