For example:
y=3x+ 1
Because we don't know the coefficient and constant term before x, we usually need to set it to a, b, a and b.
Find the average value of x and y first. x,y
Then use the formula to solve: b = (x1y1+x2y2+... xnyn-nxy)/(x1+x2+... xn-nx).
Then substitute the average value of x and y into a=Y-bX.
Find a and substitute it into the general formula y=bx+a to get the linear regression equation.
Extended data:
In linear regression, data are modeled by linear prediction function, and unknown model parameters are also estimated by data. These models are called linear models. The most commonly used linear regression modeling is that the conditional mean of y given x value is the affine function of X.
Generally speaking, the linear regression model can be the median or other quantile of the conditional distribution of y, assuming that x is a linear function of x ... Like all forms of regression analysis, linear regression is also a conditional probability distribution of y with a given x value, rather than a joint probability distribution of x and y.