Want to share your content on Rbloggers? click here if you have a blog, or here if you don't.
In a previous post, I gave a cursory overview of how prior information about covariate measurement error can reduce bias in linear regression.
In the comments, Rasmus Bååth asked about estimation in the absence of strong priors.
Here, I’ll describe a Bayesian approach for estimation and correction for covariate measurement error using a latentvariable based errorsinvariables model that does not rely on strong prior information.
Recall that this matters because error in covariate measurements tends to bias slope estimates towards zero.
For what follows, we’ll assume a simple linear regression, in which continuous covariates are measured with error.
True covariate values are considered latent variables, with repeated measurements of covariate values arising from a normal distribution with a mean equal to the true value, and some measurement error $\sigma_x$.
We can represent the latent variables in the model as circles, and observables as boxes:
with $\epsilon_x \sim Normal(0, \sigma_x)$ and $\epsilon_y \sim Normal(0, \sigma_y)$.
In other words, we assume that for sample unit $i$ and repeat measurement $j$:
The trick here is to use repeated measurements of the covariates to estimate and correct for measurement error.
In order for this to be valid, the true covariate values cannot vary across repeat measurements.
If the covariate was individual weight, you would have to ensure that the true weight did not vary across repeat measurements (for me, frogs urinating during handling would violate this assumption).
Below, I’ll simulate some data of this type in R. I’m assuming that we randomly select some sampling units to remeasure covariate values, and each is remeasured n.reps
times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

Here, the discrepancy due to measurement error is shown as a red segment, and the sample units that were measured three times are highlighted with green dashed lines.
I’ll use stan to estimate the model parameters, because I’ll be refitting the model to new data sets repeatedly below, and stan is faster than JAGS for these models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 

With the model specified, estimate the parameters.
1 2 3 4 5 6 7 8 9 

How did we do? Let’s compare the true vs. estimated covariate values for each sample unit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 

Here purple marks the posterior for the covariate values, and the dashed black line shows the onetoone line that we would expect if the estimates exactly matched the true values.
In addition to estimating the true covariate values, we may wish to check to see how well we estimated the standard deviation of the measurement error in our covariate.
1 2 3 4 5 6 

How many sample units need repeat measurements?
You may want to know how many sample units need to be repeatedly measured to adequately estimate the degree of covariate measurement error.
For instance, if $\sigma_x = 1$, how does the precision in our estimate of $\sigma_x$ improve as more sample units are repeatedly measured?
Let’s see what happens when we repeatedly measure covariate values for $1, 2, …, N$ randomly selected sampling units.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 

Looking at this plot, you could eyeball the number of sample units that should be remeasured when designing a study.
Realistically, you would want to explore how this number depends on the true amount of measurement error, and also simulate multiple realizations (rather than just one) for each scenario.
Using a similar approach, you might also evaluate whether it’s more efficient to remeasure more sample units, or invest in more repeated measurements per sample unit.
Rbloggers.com offers daily email updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/datascience job.
Want to share your content on Rbloggers? click here if you have a blog, or here if you don't.