I am trying to make a linear regression with fixed slope (to 1) and intercept (to 0), and finally want to remove points far from this fit using statistics.
# set slope =1
my_slope <-1
mylm <- lm(as.numeric(y) ~ 1 + offset(x*my_slope), data = mydata)
# set intercept=0
my_intercept<-0
mylim<-lim(I(x-intercept)~0+y)
I am not sure if these two codes are correct, first. If yes, is there any way to combine these two codes in a easier way?
subset(data, abs(y - 1 + x) < threshold)
, or by any other formula like squared distance. No need for a linear regression. – ziggystar