title: Bayesian error-in-variables (total least squares) model in R using MCMCglmm
body: <p>I am fitting some Bayesian linear mixed models using the <code>MCMCglmm</code> package in <code>R</code>. My data includes predictors that are measured with error. I'd therefore like to build a model that takes this into account. My understanding is that a basic mixed effects model in <code>MCMCglmm</code> will minimize error only for the response variable (as in <code>ols</code> regression). In other words, vertical errors will be minimized. I'd like to minimize errors orthogonal to the regression line/plane/hyperplane.</p>
  
  <ol>
  <li>Is it possible to fit an error-in-variables (aka total least
  squares) model using <code>MCMCglmm</code> or would I have to use JAGS/STAN to
  do this?  </li>
  <li>Is it possible to do this with multiple predictors in the
      same model (I have some models with 3 or 4 predictors, each measured
      with error)?  </li>
  <li>If it is possible, how would I specify the model?</li>
  </ol>
  
  <p>I've included a data set below, with a random variable <code>height</code> that is measured with error to illustrate a basic set up with <code>MCMCglmm</code>.</p>
  
  <pre><code>library(nlme)
  library(MCMCglmm)
  
  data(Orthodont)
  
  set.seed(1234)
  
  Orthodont$height &lt;- c(rnorm(54, 170, 10), rnorm(54, 150, 10))
  
  prior1 &lt;- list(
      B = list(mu = rep(0, 3), V = diag(1e+08, 3)), 
      G = list(G1 = list(V = 1, nu = 1, alpha.mu = 0, alpha.V = 1000)), 
      R = list(V = 1, nu = 0.002)
  )
  
  model1 &lt;- MCMCglmm(
      fixed = distance ~ height + Sex,   
      random = ~ Subject, 
      rcov = ~ units,
      data = Orthodont, 
      family = "gaussian",  
      prior = prior1,
      nitt = 1.1e+4, 
      thin = 10, 
      burnin = 1e+3,
      verbose = FALSE
  )
  
  summary(model1)
  </code></pre>