Answered step by step
Verified Expert Solution
Question
...
1 Approved Answer
Question 3.1 Compute the correlation coefficient between outcomes and spreads. (5 points) Note: It might be helpful to use the correlation function. In [34]: spread_r
Question 3.1 Compute the correlation coefficient between outcomes and spreads. (5 points) Note: It might be helpful to use the correlation function. In [34]: spread_r = correlation (spreads . column ( 'Spread' ), spreads. column( 'Outcome' ) ) spread_r Out [34] : 0. 49181413688314235 In [35]: grader. check("q3_1") Out [35]: q3_1 passed! Hint: Read the documentation for the predicate are . between_or_equal_to here (http://data8.org/datascience/predicates.html#datascience.predicates.are.between_or_equal_to.) In [36]: spreads_around_5 = spreads. where ( 'Spread', are. between_or_equal_to (3.5, 6.5) ) spread_5_outcome_average = np. average ( (spreads_around_5) . column ( ' Outcome' ) ) print ("Average outcome for spreads around 5:", spread_5_outcome_average) Average outcome for spreads around 5: 4. 9941176470588236 In [37]: grader. check("q3_2") Out [37] : q3_2 passed! In [44]: compute_tbl = spreads . select ('Spread', 'Outcome' ) estimates = parameter_estimates (compute_tbl) spread_slope = correlation ( spreads . column ("Spread"), spreads . column ("Outcome") ) * np. s spread_intercept = np. mean (compute_tbl. column ( 'Outcome' ) ) - spread_slope * np. mean (com print ("Slope:", round (spread_slope, 3) ) print ("Intercept", round (spread_intercept, 3) ) Slope: 0.954 Intercept 0. 22
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started