Estimating the slope and intercept in python using linear regression -


for assignment have been asked run code below.

# import numpy import numpy np import numpy.random npr import numpy.linalg npl # simulate data in end of lecture 4 - time of higher dimension n = 1000 npr.seed(123) x_1 = npr.uniform(0,10,n) x_2 = npr.uniform(0,10,n) x_3 = npr.uniform(0,10,n) x_4 = npr.uniform(0,10,n) y = 3 + 2*x_1 - x_2 + 0.5*x_3 - 0.1*x_4 + npr.normal(0,1,n) # create design matrix x 5 columns, first of 1   subsequent ones x_1, x_2, etc x = np.array(([1]*n,x_1,x_2,x_3,x_4)).t 

we asked use inv function , standard equation β = (xtx)-1xty estimates of slope , intercept parameters.

we asked values intercept , coefficient of x_1 3d.p.?

if explain great new python , appreciate guidance. asked use solve function estimate of β?


Comments

Popular posts from this blog

How to show in django cms breadcrumbs full path? -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -