# Bayesian errors-in-variables model definition in JAGS and symbolically

I'm fairly new to probability theory and am attempting to understand and implement an errors-in-variables simple linear regression model. I am assuming a model of the form

$$Y=\theta X_a+\epsilon_Y \\ X_a=X_o+\epsilon_X$$ where $X_a$ is the true (unknown) covariate and $X_o$ is the covariate observed with error.

This r-bloggers post describes the JAGS model that seems to fit the bill:

model {
## Priors
alpha ~ dnorm(0, .001)
beta ~ dnorm(0, .001)
sdy ~ dunif(0, 100)
tauy <- 1 / (sdy * sdy)
taux ~ dunif(.03, .05)

## Likelihood
for (i in 1:n){
truex[i] ~ dnorm(0, .04)
x[i] ~ dnorm(truex[i], taux)
y[i] ~ dnorm(mu[i], tauy)
mu[i] <- alpha + beta * truex[i]
}
}


What is unclear to me is how exactly this JAGS model would be expressed in probability notation.

According to Bayes' Rule, my intuition of the high-level form of the model I want is

$$P(\theta,X_a|Y,X_o)\propto P(Y,X_o|\theta, X_a) P(\theta,X_a),$$

since $\theta$ and $X_a$ are both dependent on the data $Y$ and $X_o$. How can this be expressed in simpler terms? How would the above JAGS model be expressed symbolically as Bayes' Rule?

EDIT: Clarity

• What do you mean by expressing it as "formula"?
– Tim
May 27, 2016 at 21:20
• Sorry, I should've been clearer. I mean symbolically in the form of Bayes' Rule. May 27, 2016 at 21:41

JAGS model notation is almost exactly the same as would you describe this model mathematically:

$$\alpha \sim \mathrm{Normal}(0, .001) \\ \beta \sim \mathrm{Normal}(0, .001) \\ \sigma_y \sim \mathrm{Uniform}(0, 100) \\ \tau_y = 1 / \sigma_y^2 \\ \tau_x \sim \mathrm{Uniform}(.03, .05) \\ x_{0i} \sim \mathrm{Normal}(0, .04) \\ x_i \sim \mathrm{Normal}(x_{0i}, \tau_x) \\ y_i \sim \mathrm{Normal}(\mu_i, \tau_y) \\ \mu_i = \alpha + \beta x_{0i} \\$$

it can be shown as a directed acyclic graph: or if you want it as a single formula:

$$p(\alpha,\beta,x_{0i},\tau_y,\tau_x|y_i,x_i) \propto \\ \underbrace{p(y_i|\alpha,\beta,x_{0i},\tau_y) ~ p(x_i|x_{0i},\tau_x)}_{\text{likelihood}} ~ \underbrace{p(x_{0i}) ~ p(\alpha) ~ p(\beta) ~ p(\tau_x) ~ p(\tau_y)}_{\text{priors}}$$

but the latter "simplification" yields much less information than the initial specification (or BUGS code specification). Because of that it is much more popular to describe models in the form listing all the random variables rather then by using Bayes theorem formula.