get_slope: Return slope in orthogonal regression problem

Description Usage Arguments Details Value See Also Examples

View source: R/orthogonal.R

Description

Return slope in orthogonal regression problem

Usage

1
get_slope(x, y)

Arguments

x

vector with independent variable

y

vector with dependent variable

Details

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.

Value

the slope of the line that minimizes the total least squared error

See Also

sum_squares(), get_slope_by_group() For a more general function (including one that returns the intercept), see pracma::odregress()

Examples

1
2
3
4
5
n <- 1000
z <- rnorm(n)
x <- rnorm(n, z)
y <- rnorm(n, 2 * z + 1)
get_slope(x, y)

psadil/nmmr documentation built on June 13, 2021, 11:42 a.m.