LinearRegressionFP: One Pass Linear Regression with fixed point.

Description Usage Arguments Details Value Examples

View source: R/LinearRegression.R

Description

This function performs Linear Regression on the input data with a fixed point. It uses a one pass algorithm implemented in C++. This is for users who only need m and c from the y=mx + c equation. Compared to the lm function, this function is much faster.

Usage

1
LinearRegressionFP(x, y, x1, y1)

Arguments

x

Numeric vector. x values.

y

Numeric vector. corresponding y values.

x1

Numeric. x coordinate of the fixed point.

y1

Numeric. y coordinate of the fixed point.

Details

This function calculates m and c in the linear equestion, y = mx + c.

Value

This function returns a list with one object, "coefficients". The first element in this object is c; the second element is m in the y = mx + c equation.

Examples

1
2
3
4
5
6
7
x <- 1:10
y <- 1:10
x1 <- 1
y1 <- 2
results <- LinearRegressionFP(x,y, x1, y1)
m <- results$coefficients[[2]]
c <- results$coefficients[[1]]

Example output



Linnorm documentation built on Nov. 8, 2020, 6:48 p.m.