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

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

1 Answer 1


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:

enter image description here

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.