(Solved) : Exercise 2 3 Points Calculate Standard Errors Parameters Recall Van 2 Xrx Ne 1 M Number Da Q37457985 . . .

![serr std error(X,y,theta) print (np. sum(serr)) 0.006273507559132202 exercise2 points) In [12]: Test assert serr.shape[ 0]6](https://media.cheggcdn.com/media%2F503%2F5039c6ef-c34f-4d46-afd1-8830a11ecb28%2FphpyU07UP.png)
Exercise 2 (3 points): Calculate standard errors for parameters. Recall that van@ ,2(XrX)-ї a? , where ne i-1 m is the number of data points k is the number of predictors and . epsilon is the difference between actual and predicted value i.e. e y f se(9) diagonal elements of / var(6) Hint: According to above formula, the standard errors are the diagonal elments of squared root of var(θ) Define the following function and return standard errors for parameters. Set the ‘serr” array with the standard errors. Note: return value should be an array of dimensions (k+1) X 1, where k is the number of predictors In 11: def std_error(X, y. theta): nr, rankx.shape rank -1 resid df nr – rank + 1 residvarss_res(X, y, theta) / resid df var_theta-residvar* np.linalg.inv(X.T.dot (X)) return np.diag(scipy.linalg.sqrtm(var_theta)):,None] ### set “serr” here serrstd_error (X,y, theta) print(np.sum(serr)) serr std error(X,y,theta) print (np. sum(serr)) 0.006273507559132202 exercise2″ points) In [12]: Test assert serr.shape[ 0]6 assert serr.shape[1] 1 assert np . round (np . sum(serr ) ,4) 0.0068 assert (np. round ( serr [1] + serr[3] ,5) 0.0022) assert (np.round (serr2 +serr[41,5) 0.0022) assert (np.round ( serr[5] + serr[0],5)0.00237) print(“Passed!”) cell: (3 AssertionError Traceback (most recent call last) <ipython-input-12-50b16a778cb0> in <module> () 2 assert serr. shape [01-6 3 assert serr.shapel1 -> 4 assert np.round (np. sum (serr),40.0068 5 assert (np.round (serr1serr[3],5)0.0022) 6 assert (np.round ( serr[2] +serr4],5)0.0022) AssertionError: Show transcribed image text
Expert Answer
Answer to Exercise 2 3 Points Calculate Standard Errors Parameters Recall Van 2 Xrx Ne 1 M Number Da Q37457985 . . .
OR