Hi, and welcome!
A reproducible example, called a reprex always helps clarify questions. I'll have to assume that you mean an ordinary least squares regression using lm()
. A reprex
would look like
fit <- lm(mpg ~ wt, data = mtcars)
abs_fit <- abs(fit$residuals)
sort(abs_fit)[1]
#> Merc 450SL
#> 0.0502472
Created on 2020-01-15 by the reprex package (v0.3.0)
This interprets the best fit as meaning has the smallest absolute residual, meaning lies closest to the trend line..