# Weak identifiability in measurement models

**URL:** <https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600>\
**Category:** Modeling\
**Tags:** specification\
**Created:** [January 13, 2020, 3:01am UTC](https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600 "2020-01-13T03:01:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duncan](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/duncan/32/4571_2.png) [@Duncan](https://discourse.mc-stan.org/u/Duncan)\
**Post date:** [January 13, 2020, 3:01am UTC](https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600/1 "2020-01-13T03:01:46Z")

</div>

Hi! I am trying to further my understanding of measurement models and trying to write them in raw stan. In this model, there is dependence on V from the outcome and all other variables, I, P, and Y. Currently, I have ‘I’ modeled with hierarchical priors, and ‘P’ is just linked through a linear model. I had also tried hierarchical priors on ‘P’. Although I would welcome feedback on any improvements in the code, the particular problem is with that beta5 and beta2 are not identifiable (no updating from prior). The data are simulated so I know updating should occur. They are coefficients on the same data, so it makes sense to me that they would be difficult to distinguish.  
How can I deal with this issue?  
Also, the model returns no warnings.  
Thank you!

Here is the model

```
 "
data {
int<lower=0> N; // cases 
vector[N] I_p; // I observed
vector[N] I_e; // I error
vector[N] V; // measured without error
vector[N] Y; // outcome 
vector[N] P_p; // P observed 
vector[N] P_e; // P error 
}

parameters {
vector[N] I_true; 
real <lower=0> sigma_y;
real <lower=0> sigma_I;
real beta1;
real beta2;
real beta3;
real beta4;
real beta5;
real beta6;
real alpha1;
real alpha2;
real alpha3;
}

transformed parameters {
vector[N] P_true;
vector[N] I_t;
P_true = alpha1 + beta1*V; // measurement model for P
I_t = alpha2 + beta2*V + beta3*P_true + I_true*sigma_I; // measurement model for I
}

model {
beta1 ~ normal(0,.3);
alpha1 ~ normal(0, .2);
sigma_I ~ normal(0,.2);
alpha2 ~ normal(0,.3);
beta2 ~ normal(0, .3);
beta3 ~ normal(0, .5);
P_p ~ normal(P_true, P_e);
I_true[N] ~ std_normal(); 
I_p ~ normal(I_true, I_e);
sigma_y ~ exponential(1);
beta4 ~ normal(0,.5);
beta5 ~ normal(0,.4);
beta6 ~ normal(0,.4);
alpha3 ~ normal(0,.5);
Y ~ normal(alpha3 + beta4*I_t + beta5*V + beta6*P_true, sigma_y);
}

generated quantities {
  vector[N] y_pred;
  for(i in 1:N) {
    y_pred[i] = alpha3 + beta4 * I_t[i] + beta5 * V[i] + beta6 * P_true[i];
  }
}

"

```

I have attached a pairs plot that shows several unhappy pairs

 ![mcmcdiag](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/d/d377e7776ae9ca2acc75c052878339284fbab243.png)

---

<div class="post-metadata">

**Author:** ![chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chris](https://discourse.mc-stan.org/u/chris)\
**Post date:** [January 13, 2020, 4:13pm UTC](https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600/2 "2020-01-13T16:13:18Z")

</div>

There are a couple of things that you might want to try.

First, it seems like you’re trying to overconstrain your data with really specific priors like normal(0,.2). If your data fits the model, it’ll fit the correct values without needing a very specific prior. You should be able to try out normal(0,1) or even normal(0,10).

Second, your sigma\_y is probably not an exponential which means the mode is at zero. You should try a cauchy or gamma or something.

Third, make sure you start by fitting fake data, then move onto fitting your real data one parameter at a time. This is the most important thing for bespoke Bayesian modeling, but I tend to find myself skipping this step and having to start over every time.

Hope this helps a little.

---

<div class="post-metadata">

**Author:** ![Duncan](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/duncan/32/4571_2.png) [@Duncan](https://discourse.mc-stan.org/u/Duncan)\
**Post date:** [January 13, 2020, 5:26pm UTC](https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600/3 "2020-01-13T17:26:42Z")

</div>

Ok, back to the drawing board, thank you!

---

<div class="post-metadata">

**Author:** ![Duncan](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/duncan/32/4571_2.png) [@Duncan](https://discourse.mc-stan.org/u/Duncan)\
**Post date:** [January 20, 2020, 1:55pm UTC](https://discourse.mc-stan.org/t/weak-identifiability-in-measurement-models/12600/4 "2020-01-20T13:55:03Z")

</div>

I think there was a problem with the simulation, I reworked it, and now I can recover parameters with a centered parameterization, and N(0,1) on all coefficients. However, I get warnings with ESS and energy, particularly with sigma\_y. If I specify a prior away from 0 (i.e. N(1,.3) or something) I can avoid divergences however the other warnings remain. I’ve attached a pairs plot with normal priors on sigma\_I and sigma\_P, and a gamma(2,1) on sigma\_y.  
Do you have any ideas how to make this more efficient?

 ![Screen Shot 2020-01-20 at 8.51.24 AM](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/c/c07a6a49ce315e0122b1c37660e28ce5d366e4ad.jpeg)
