# "Measurement error" model

**URL:** <https://discourse.mc-stan.org/t/measurement-error-model/31875>\
**Category:** Modeling\
**Created:** [June 26, 2023, 11:46pm UTC](https://discourse.mc-stan.org/t/measurement-error-model/31875 "2023-06-26T23:46:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![js592](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@js592](https://discourse.mc-stan.org/u/js592)\
**Post date:** [June 26, 2023, 11:46pm UTC](https://discourse.mc-stan.org/t/measurement-error-model/31875/1 "2023-06-26T23:46:19Z")

</div>

I’ve been working on a linear regression problem where we don’t measure the covariate of interest (x\_{true}) directly:

y \sim Normal(a+b\*x\_{true},\sigma\_1)

Instead we measure a proxy variable (x\_{obs}) and have calibration data available to fit another regression between the proxy variable and the covariate of interest:

x\_{true} \sim Normal(c+d\*x\_{obs},\sigma\_2).

For now, assume we will just use the point estiamtes of c,d,\sigma\_2

I’ve coded the model as following:

```stan
data {
  int<lower=0> N;
  vector[N] y;
  vector[N] x_obs;
  real sigma_2;
  real c;
  real d;
}

parameters {
  real a;
  real b;
  vector[N] x_true;
  real<lower=0> sigma_1;
}

model {
  a ~ normal(0,5);
  b ~ normal(0,5);
  sigma ~ cauchy(0,5);
  x_true ~ normal(c+d*x_obs,sigma_2);
  y ~ normal(a+b*x_true, sigma_1);
}

```

Would this be the right implementation? And, in general, will models like this lead to a different likelihood formulation than traditional measurement error models that suppose x\_{obs} \sim Normal(x\_{true},\tau) for known measurement error \tau or is there some equivalence I’m missing?

---

<div class="post-metadata">

**Author:** ![jsocolar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jsocolar/32/2486_2.png) [@jsocolar](https://discourse.mc-stan.org/u/jsocolar)\
**Post date:** [June 27, 2023, 1:09am UTC](https://discourse.mc-stan.org/t/measurement-error-model/31875/2 "2023-06-27T01:09:10Z")

</div>

This is exactly equivalent. To see the equivalence, note that you have written down `x_true ~ normal(x_obs2, sigma2)` where `x_obs2 = c+d*x_obs`. Then notice that `normal_lpdf(x_true | x_obs2, sigma2)` is strictly equal to `normal_lpdf(x_obs2 | x_true, sigma2)`. Thus you have a model that is precisely equivalent to

> [@js592](#):
>
> xobs∼Normal(xtrue,τ)

where \tau is `sigma2` and x\_{obs} is `x_obs2`.
