I am fitting some Bayesian linear mixed models using the MCMCglmm
package in R
. 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 MCMCglmm
will minimize error only for the response variable (as in ols
regression). In other words, vertical errors will be minimized. I'd like to minimize errors orthogonal to the regression line/plane/hyperplane.
- Is it possible to fit an error-in-variables (aka total least
squares) model using
MCMCglmm
or would I have to use JAGS/STAN to do this? - 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)?
- If it is possible, how would I specify the model?
I've included a data set below, with a random variable height
that is measured with error to illustrate a basic set up with MCMCglmm
.
library(nlme)
library(MCMCglmm)
data(Orthodont)
set.seed(1234)
Orthodont$height <- c(rnorm(54, 170, 10), rnorm(54, 150, 10))
prior1 <- 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 <- 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)