How do I perform linear regression on data?

1 Answer
Apr 22, 2018

You need to see full answer to understand

Explanation:

I don't fully know what you mean first you get your data set where you regress y on x to find how a change in x effects y.

x y
1 4
2 6
3 7
4 6
5 2

And you want to find the relationship between x and y so say you believe the model is like

#y=mx+c#

or in stats

#y=beta_0+beta_1x+u#

these #beta_0,beta_1# are the parameters in the population and #u# is the effect of unobserved variables otherwise called the error term so you want estimators #hatbeta_0,hatbeta_1#

So #haty=hatbeta_0+hatbeta_1x#

This tells you that the predicted coefficents will give you the predicted y value.

So now you want to find the best estimates for these co-efficents we do this by finding the lowest difference between the actual y value and predicted.

#min sum_(i=1)^nhatu_i^2~hatbeta_0,hatbeta_1#

This basically says that you want the minimum of the sum of the differences between the acutal y values and predicted y values for your regression line

enter image source here

So the formulas for finding them are

#hatbeta_1=(sum_(i=1)^n(x_i- barx)(y_i-bary))/(sum_(i=1)^n(x_i-barx)^2)#

#hatbeta_0=bary-hatbeta_1barx#