Skip to contents

A = (mean(xy) - mean(x)mean(y))/(mean(x^2) - mean(x)^2), B = mean(y) - A mean(x) (both book forms cross-checked), residual sum of squares, sample r with the 1/n covariance, and the slope product A*C = r^2. Mirrors morie.fn ch6 data modules (and the misnamed "19e2").

Usage

morie_least_squares(x, y)

Arguments

x, y

data vectors, length >= 2.

Value

list: A, B, S, r, C, slope_product.

References

Morin (2016), eqs. (6.12)-(6.14), (6.42)-(6.55), (6.82), (6.92).

Examples

morie_least_squares(c(2, 3, 3, 5, 7), c(1, 1, 3, 4, 6))$A
#> [1] 1