0
import numpy as np
import statsmodels.api as sm
duncan_prestige = sm.datasets.get_rdataset("Duncan", "carData")
Y = duncan_prestige.data['income']
print(Y.shape)
X = duncan_prestige.data['education']
print(X.shape)
X = sm.add_constant(X)
print(X.shape)
model = sm.OLS(Y,X)
results = model.fit()
model.predict(X)
results.params

Error: ValueError: shapes (45,2) and (45,2) not aligned: 2 (dim 1) != 45 (dim 0). How can I predict on training set? (I need to plot the regression line with additional data via plt.plot)

Jedi Knight
  • 367
  • 2
  • 10

1 Answers1

0

Should have called

results.predict(X)
Jedi Knight
  • 367
  • 2
  • 10