Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the sm . OLS function to create a model object to fit y to x , and assign the result to the variable model.

Use the sm.OLS function to create a model object to fit y to x, and assign the result to the variable model. Also pass in the option missing='drop' to drop any observations with missing data in either x or y. As before, you might find it useful to consult the statsmodels documentation on OLS.
Call the fit method on model to fit the model to the data, and store the output in results
Print the results of the fit, by calling the results.summary method.Plot the model results via a call to sm.graphics.abline_plot, passing in the results object computed above in the model_results option, and assign the plot output to the variable fig
Extract the relevant plotting axes with the following expression: ax = fig.axes[0]
Call the method ax.scatter with two arguments to plot Happiness versus LogGDP (recall that LogGDP is now a particular column in the variable x that you have created: x['LogGDP'])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions