My question is somewhat related to other examples, such as here: Measurement error? model,
but my efforts to follow the guidance I’ve read have not been successful.
I am considering the case where we want to estimate a linear relationship between two variables, X and Y, where both are measured/observed with error. To help identify the parameters, I assume that I know the standard deviation of the error in measuring X.
I am simulating data by selecting points on a line and perturbing them. Even when I specify the correct value of sigma_X, I am seeing loads of divergent transitions.
I am interested in using Stan to fit more general versions of this model. Could you all help me get it off the ground?
You’re missing a zero lower bound on the variance parameter sigma_y. You can also nix the for loops by defining things as vectors rather that arrays of reals.
Furthermore, fitting this model over several similarly simulated data sets, beta is consistently estimated to be less than 1. I’m looking for an explanation as to why.
Thanks, I think your changes make the model easier to comprehend. Unfortunately, I continue to get divergent transitions. Here is an updated .stan model file incorporating all suggested changes so far.
I reparammeterize “xraw” in the model, set adapt_delta to 0.95, run two chains of 10,000 iterations each, and still get about 20 divergent transitions.
As suggested in Brief Guide to Stan website, " it might actually work if the number of divergent transitions is small" . I don’t know whether it’s OK.
I suppose the problem rises when the parameter “mu” is the product of two parameters “xraw” and “beta”
In case it helps, we discuss this in the MCMC diagnostics section in [1709.01449] Visualization in Bayesian workflow and show a few visualizations that sometimes can be used to tell whether or not a small number of divergences is a problem.
Thanks a lot !
According to my limited experience, divergent transitions easily emerges if there are transformed parameters which are non-linear functions of two or more pre-declared parameters. When I run my own stan model of Major Axis Regression, there are many divergent transitions. I don’t know how to handle the problem and hope for your help. Jacobian determinent
Thanks again!