Skip to content

Instantly share code, notes, and snippets.

@pytholabsbot1
Created January 30, 2019 17:31
Show Gist options
  • Save pytholabsbot1/d127ea7d8caaeebe4a2d57f06fb197d0 to your computer and use it in GitHub Desktop.
Save pytholabsbot1/d127ea7d8caaeebe4a2d57f06fb197d0 to your computer and use it in GitHub Desktop.
##create a nodel to estimate the relationship b/w x and y
##optimization model = OLS estimator
def ols(x,y):
y_ = y.mean()
x_ = x.mean()
b1 = np.sum((y-y_)*(x-x_))/np.sum((x-x_)**2)
b0 = y_- b1*x_
return(b0,b1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment