3
$\begingroup$

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?

$\endgroup$
12
  • 1
    $\begingroup$ 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. $\endgroup$
    – whuber
    Commented Jan 4, 2017 at 19:13
  • $\begingroup$ Yes coefficient m $\endgroup$
    – Joe Wragg
    Commented Jan 4, 2017 at 19:14
  • $\begingroup$ 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. $\endgroup$
    – whuber
    Commented Jan 4, 2017 at 19:18
  • 1
    $\begingroup$ 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." $\endgroup$
    – whuber
    Commented Jan 4, 2017 at 19:24
  • 2
    $\begingroup$ @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. $\endgroup$ Commented Jan 4, 2017 at 19:29

1 Answer 1

0
$\begingroup$

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.

On the other hand, the standard error of the slope is based on the variability in your observed data. Since this is what was used to fit the slope, and slopes fit on data with measurement error should bounce around more widely that slopes fit on data measured without measurement error. As a result, I would not advise you to try to remove the variance of the measurement error from the standard errors of your regression parameters. They are correct already.

$\endgroup$

Your Answer

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

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