# Linear Regression Example

Linear Regression is an approach to modeling the relationship between two variables by fitting a linear equation to observed data. This worksheet help you to understand how to perform linear regression calculation by using the below formula,
Y = A + BX

Formula to calculate Mean

Formula to calculate slope
Slope = (∑XY - N x Xbar x Ybar)/(∑X2 - N x Xbar2)

Formula to calculate Intercept
A = Ybar - slpoe x Xbar

Example for Linear Regression:
Calculate the Linear Regression whose input values are X = [5,20,40,80,100] & Y = { 10,20,30,40,50}
Substitute these values in the above formula, we get

To find X Mean
Total Inputs(N) =(5,20,40,80,100)
Total Inputs(N)=5
Mean(xm)= (x1+x2+x3...xn)/N
Mean(xm)= 245/5
Mean(xm)= 49

To find Y Mean
Total Inputs(N) =(10,20,30,40,50)
Total Inputs(N)=5
Mean(Ym)= (y1+y2+y3...yn)/N
Mean(Ym)= 150/5
Mean(Ym)= 30

To find Slope
Slope = (∑XY - N x X x Y)/(∑X2 - N x X)
= [(50+400+1200+3200+5000) - (5 x 30 x 49)]/[(25+400+1600+6400+10000) -( 5x492)]
= (9850 - 7350) /(18425 - 12005)
= 2500/6420
= 0.3894

To find Intercept Value:
A = Ybar - Slope x Xbar
= 30 - (0.3894 x 49)
= 10.9194.

To find Linear Regression:
Y = A + Bx
Answer = 10.9194 + 0.3894 X

When you try to solve linear regression problem, this linear regression calculator can be used to verify your results.