# linreg#

linreg(close, length=None, offset=None, **kwargs)[source]#

Linear Regression Moving Average (linreg)

Linear Regression Moving Average (LINREG). This is a simplified version of a Standard Linear Regression. LINREG is a rolling regression of one variable. A Standard Linear Regression is between two or more variables.

Source: TA Lib

Calculation:
Default Inputs:

length=14

x = [1, 2, …, n] x_sum = 0.5 * length * (length + 1) x2_sum = length * (length + 1) * (2 * length + 1) / 6 divisor = length * x2_sum - x_sum * x_sum

lr(series):

y_sum = series.sum() y2_sum = (series* series).sum() xy_sum = (x * series).sum()

m = (length * xy_sum - x_sum * y_sum) / divisor b = (y_sum * x2_sum - x_sum * xy_sum) / divisor return m * (length - 1) + b

linreg = close.rolling(length).apply(lr)

Args:

close (pd.Series): Series of ‘close’s length (int): It’s period. Default: 10 offset (int): How many periods to offset the result. Default: 0

Kwargs:
angle (bool, optional): If True, returns the angle of the slope in radians.

Default: False.

degrees (bool, optional): If True, returns the angle of the slope in

degrees. Default: False.

intercept (bool, optional): If True, returns the angle of the slope in