I am trying to do linear regression between GDP and Count columns on data set below:
Here is my code:
CT = slav_df.iloc[:, 4]
GDP = slav_df.iloc[:,3]
t_slope, t_int, t_r, t_p, t_std_err =
stats.linregress(GDP, CT)
talent_fit = t_slope * CT + t_int
#plotting
fig, (ax1) = plt.subplots(1, sharex=True)
fig.suptitle(" ", fontsize=16, fontweight="bold")
ax1.set_xlim(min(CT), max(CT))
ax1.plot(GDP, CT, linewidth=1, marker="o")
ax1.plot(GDP, talent_fit, "b--", linewidth=1)
ax1.set_ylabel(" ")
When I run this I am getting a graph like this:
This doesn't seem to be right and I am wondering if I am doing something wrong here?