# Standard errors for slope and residual variance with measurement error in Y

I am using R to estimate the error in the slope of a regression line. (I will later use the slope to calculate something.) I have some data, call them $x$ and $y$, and will fit a linear regression such as $y = mx+c$. If y has some error associated with it, say $\delta y = 0.1$ for example, what is the error in the slope?

The residual standard error given by the lm() function in R does not take this error in y into account. So how do I take the residual standard error and add the error in y that I have?

• Could you please explain what you mean by "gradient"? One would have supposed you mean the coefficient $m$, but you contradict that where you claim lm does not account for the errors in y. – whuber Jan 4 '17 at 19:13
• Yes coefficient m – Joe Wragg Jan 4 '17 at 19:14
• Okay. What is the reason you claim "the lm() function in R does not take into account this error in y"? Because that's untrue, we ought to explore the origin of this misbelief because it might help us understand what question you're actually trying to formulate. – whuber Jan 4 '17 at 19:18
• I don't see anything that is incorrect in that description when it's properly interpreted. The squares of the residuals automatically incorporate any variation in the responses $y$: that's part and parcel of what least squares does. I suspect you will need to explain, as clearly as possible, what you mean by "error bars on my points." – whuber Jan 4 '17 at 19:24
• @whuber, I think he means that OLS assumes your data are measured w/o error, & that the resulting estimated error variance will be the sum of the true error variance and the variance of the measurement error. – gung - Reinstate Monica Jan 4 '17 at 19:29

Let's consider the simplest case: There is measurement error in $Y$ only. It is normally distributed, centered on the true value of each $y_i$, and independent (of the value of $y_i$, $x_i$, etc.). We'll say the standard deviation of the measurement error is $0.1$. That seems to be the situation you have in mind.
In this case, the variance of the residuals will be inflated relative to the true variance of the errors. (Note that "errors" is the traditional—unfortunate—name of the random part of the data generating process, they are not erroneous in the everyday sense, and they are not the same as the measurement errors.) Specifically, variances add, so the expected variance of the residuals will be the true variance of the errors plus the variance of the measurement error. What R calls the "residual standard error" is (somewhat bizarrely) the standard deviation of the residuals (cf., here), so you need to square that to get the variance. If you knew the variance of the measurement error a-priori, or had some independent estimate of it, you could simply subtract that value from the result. If you'd like, you could take the square root of the difference to get an estimate of the SD of the errors.