OLS of statsmodels does not work with inversely proportional data?
问题 I'm trying to perform a Ordinary Least Squares Regression with some inversely proportional data, but seems like the fitting result is wrong? import statsmodels.formula.api as sm import numpy as np import matplotlib.pyplot as plt y = np.arange(100, 0, -1) x = np.arange(0, 100) result = sm.OLS(y, x).fit() fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(20, 4), sharey=True) ax.plot(x, result.fittedvalues, 'r-') ax.plot(x, y, 'x') fig.show() 回答1: You're not adding a constant as the