Functions to perform linear regression.
Usage
simple_ordinary_least_squares(x, y)
simple_ordinary_least_squares_with_R_squared(x, y)
Arguments
- x
A numeric vector.
- y
A numeric vector.
Value
A two-element numeric vector containing the intercept and slope of the regression line,
or a three-element vector containing the intercept, slope, and R-squared value if applicable.
Examples
# Simple Ordinary Least Squares
x <- c(1, 2, 3, 4, 5)
y <- c(2, 3, 5, 7, 11)
simple_ordinary_least_squares(x, y)
#> [1] -1.0 2.2
# Simple Ordinary Least Squares with R-squared
simple_ordinary_least_squares_with_R_squared(x, y)
#> [1] -1.0000000 2.2000000 0.9453125