Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please how can you do this using python? 9. The simple linear regression model is used to study the relationship between two variables and is

please how can you do this using python? image text in transcribed
image text in transcribed
9. The simple linear regression model is used to study the relationship between two variables and is defined as y=0+1z+c where: - y and z are data points; - Bo 0 is the y-intercept - 1 is the slope; and, - e is a stochastic error term. The most common method used to estimate the simple linear regression model is via ordinary least squares (OL.S). Solving for 0 and 1, using the OLS methodology, we get that 0=y1z1=(zz)2(zz)(yy), where y is the mean value of x, and y is the mean value of y. a. Using only built-in functions and list comprehension (no using of external libraries or modules, no using of for or while loops, and no using of if statements) write code that derives the values of 0 and 1 using the following data: x=[8,2,11,6,5,4,12,9,6,1]y=[3,10,3,6,8,12,1,4,9,14] Print out the values of 0 and 1. b. Given the values of 0 and 1, the predicted values of y can be calculated as y=0+1= Using list comprchension, derive the values of y and print out the mean value of y and of g. ordinary least squares (OLS). Solving for 0 and 1, using the OLS methodology, we get that 0=y1z1=(xx)2(xz)(yy), where x is the mean value of x, and y is the mean value of y. a. Using only built-in functions and list comprehension (no using of external libraries or modules, no using of for or while loops, and no using of if statements) write code that derives the values of 0 and 1 using the following data: x=[8,2,11,6,5,4,12,9,6,1]y=[3,16,3,6,8,12,1,4,9,14] Print out the values of 0 and 1. b. Given the values of 0 and 1, the predicted values of y can be calculated as y^=0+1x. Using list comprehension, derive the values of y^ and print out the mean value of y and of y^. c. Using equation (2) and the values of 0 and 1, we can calculate the predicted values of the stochastic error terms as c=y(0+1x)=yy. Using list comprehension, derive the values of e and print its mean

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions