Open drbigshog opened 21 hours ago
Hi, I am running into an issue for Task 2 part b and c where the line I am fitting to the dependent variable is not functioning properly.
Here is my code, and here is a screenshot of the result. The scatter plot appears fine, but the line isn't working as it did in part a).
This happens in both questions but here is part b):
formula_2 = 'co2_per_capita ~ income' res2 = smf.ols(formula=formula_2, data=world_data_2014).fit()
sns.scatterplot(x='income', y='co2_per_capita', data=world_data_2014) plt.plot(world_data_2014.income,results.fittedvalues)
I looked online, and some sites suggested sorting the data, but I'm curious why this code doesn't work as expected. Thanks!
Solved it, should have res2 and res3.fittedvalues instead of resultds
Hi, I am running into an issue for Task 2 part b and c where the line I am fitting to the dependent variable is not functioning properly.
Here is my code, and here is a screenshot of the result. The scatter plot appears fine, but the line isn't working as it did in part a).
This happens in both questions but here is part b):
formula_2 = 'co2_per_capita ~ income' res2 = smf.ols(formula=formula_2, data=world_data_2014).fit()
sns.scatterplot(x='income', y='co2_per_capita', data=world_data_2014) plt.plot(world_data_2014.income,results.fittedvalues)
I looked online, and some sites suggested sorting the data, but I'm curious why this code doesn't work as expected. Thanks!