title: How to get the "in-sample" predicted values (y hat) in statsmodel ols?
body: <p>Here is the code:</p>
  
  <pre><code>from   statsmodels.formula.api import ols
  import io
  import requests
  
  url = "https://raw.githubusercontent.com/RInterested/datasets/gh-pages/mtcars.csv"
  contents = requests.get(url).content
  mtcars = pd.read_csv(io.StringIO(contents.decode('utf-8')))
  print(mtcars.describe())
  reg = ols('mpg ~ C(cyl) + wt', data=mtcars).fit() 
  print(reg.summary())
  </code></pre>
  
  <p>This seems to return an intercept for the model, and the syntax is very similar to R, which I like. There is a <code>reg.predict</code> and a <code>reg.get_predict</code> within the <code>print(dir(reg))</code>, but neither one of them return the predicted values for each example (case or subject) in the dataset. It seems as though it may be waiting for an "out-of-sample" array to spit out these predicted values.</p>
  
  <p>I would like to get the predicted <code>mpg</code> for the examples in the actual dataset plotted as points of a different color to the actual data cloud, and superimposed on the regression line:</p>
  
  <p><a href="https://i.stack.imgur.com/5kT6P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5kT6P.png" alt="enter image description here"></a></p>