## Help with Measurement Error Syntax

Help
Glen210
2011-02-04
2012-09-01

• Glen210
2011-02-04

I'm trying to fit a bivariate mixture of normals with measurement error in
both X and Y and model the true values. I'm trying to fit something like below
(some parts omitted):

``` for (i in 1:n){
x_obs[i] ~ dnorm(x_true[i],prec_x)I(x_true[i],)
y_obs[i] ~ dnorm(y_true[i],prec_y)
cbind(x_true[i],y_true[i])~dmnorm(mu[ z [ i ],1:2], tau[z[i],1:2,1:2])
z[i]~dcat(prob[ ])
}

#priors for measurement error
e_x~dunif(.1,.9)
prec_x<-1/pow(e_x,2)
e_y~dunif(2,4)
prec_y<-1/pow(e_y,2)
```

Obviously the cbind command does not work. Any idea how I can modify it?
Thanks so much.

• Martyn Plummer
2011-02-14

The BUGS language is syntactically similar to S (R) but it is not the same.
You can get what you want by combining your x_true and y_true into a single
array xy_true, as follows:

``` for (j in 1:n){
x_obs[j] ~ dnorm(xy_true[j,1], prec_x)  T(xx_true[j,1],)
y_obs[j] ~ dnorm(xy_true[j,2], prec_y)
xy_true[j, ] ~dmnorm(mu[ z [j],1:2], tau[z[j],1:2,1:2])
z[j]~dcat(prob[ ])
}

#priors for measurement error
e_x~dunif(.1,.9)
prec_x<-1/pow(e_x,2)
e_y~dunif(2,4)
prec_y<-1/pow(e_y,2)
```

Also, JAGS does not have an I(,) construct because its use in the BUGS
language is ambiguous (see the JAGS user manual for details). I've put in a
T(,) instead assuming that you want truncation.