Return slope in orthogonal regression problem
get_slope(x, y)
x | vector with independent variable |
---|---|
y | vector with dependent variable |
the slope of the line that minimizes the total least squared error
Whereas ordinary least squares finds the line that minimizes the sum of squared vertical distance, orthogonal regressions finds the line that minimizes the sum of vertical and horizontal differences.
sum_squares()
, get_slope_by_group()
For a more general function (including one that returns the intercept), see pracma::odregress()
#> [1] 2.003767