1
$\begingroup$

Just started learning linear regression, started with a simple perfect linear regression example, X values are 1,2,3,4,5 and Y values are 1,2,3,4,5. And this is the summary I am getting:

Residuals:
         1          2          3          4          5 
-4.828e-16  8.351e-16 -2.098e-16 -1.544e-16  1.196e-17 

Coefficients:
             Estimate Std. Error   t value Pr(>|t|)    
(Intercept) 1.192e-15  6.050e-16 1.969e+00    0.144    
X           1.000e+00  1.824e-16 5.482e+15   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.769e-16 on 3 degrees of freedom
Multiple R-squared:      1, Adjusted R-squared:      1 
F-statistic: 3.005e+31 on 1 and 3 DF,  p-value: < 2.2e-16

From this wee see that the estimated linear equation is y=x+1.192 and when we calculate the residuals for the first data point it should be 1-(1+1.92) -1.92. But why the residual output shows -4.8.

How is the residual calculated here?

$\endgroup$

1 Answer 1

3
$\begingroup$

The ouptut -4.828e-16 is the scientific notation for a very small number, $-4.828 \cdot 10 ^ {-16}$. All your residuals are almost identical to zero.

res <- c(-4.828e-16,  8.351e-16, -2.098e-16, -1.544e-16,  1.196e-17) 
sapply(res, all.equal, 0)
# [1] TRUE TRUE TRUE TRUE TRUE

The values equal zero with a tolerance related to the representation of decimal numbers on a computer. Due to the limits in the representation of decimal numbers, the values are not exactly zero.

$\endgroup$
0

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.