I have defined two variables x
and y
. I want to regress y
on x
, but the sum of residuals using the lm
is non-zero
Here are the variables:
x<-c(1,10,6,4,3,5,8,9,0,3,1,1,12,6,3,11,15,5,10,4)
y<-c(2,3,6,7,8,4,2,1,0,0,6,1,3,5,2,4,1,0,1,9)
gh<-lm(y~x)
sum(gh$residuals)
# [1] 4.718448e-16
I don't understand why the sum of residuals is non-zero. It should be zero by the procedure of OLS.
Thanks