Question: USE PYTHON assignment 4 is not needed can be done without Exercise 5 Write a function ssr(y, x, beta_o, beta 1) that calculates the sum
Exercise 5 Write a function ssr(y, x, beta_o, beta 1) that calculates the sum of squared residuals for the linear regression model. SSR(y,x, Bo, B1) = (:- Bo - 3*,)? You can use the function ssr loops (y, x, beta.0, beta 1) from Assignment 4 (including the solutions) as a template. Exercise 6 Now find values of beta 0 and beta 1 that minimize ssr(y, x, beta.0, beta 1) for given x and y. Write a function min.ssr(y, x, beta 0 min, beta_O_max, beta 1 min, beta 1 max, step) as follows: a) Find these values by evaluating sar(y, x, beta.0, beta 1) over every combination of of (30.81) in two lists. b) Create lists beta 0.list and beta 1.list from ranges Bo Bonin, Sur and 3 . Bar, where the neighboring values of Bo or 81 are separated by distance step. c) Start with min.SSR - 999999. Loop over the index numbers i and 3, corresponding to lists beta 0.list and beta 1 list. d) For each pair of i and j, extract the value bota.0.list[i] and beta1.list[j]. e) For each pair of i and j, evaluate SSR y, a, 30.81). If it is lower than min SSR, record the new imin = i and j min - j and update the newest value of min SSR. f) After the loops, return ( beta.i.min), beta 1 [j min] ] g) Verify that the result matches the values in Exercises 4 and 5 (up to accuracy step)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
