title: Getting transformed X values from OLS model using statsmodels
body: <p>I am trying to do a linear regression. With the results I want to multiply each <em>x</em> with its own estimated coefficient: <em>x</em><sub>i</sub>&middot;<em>&beta;</em><sub>i</sub>.</p>
  
  <p>However, I am doing a lot of transformations on <em>x</em><sub>i</sub>.</p>
  
  <p>For example:</p>
  
  <pre><code>import statsmodels.api as sm
  import statsmodels.formula.api as smf
  import numpy as np
  
  def log_plus_1(x):
      return np.log(x + 1.0)
  
  df = sm.datasets.get_rdataset("Guerry", "HistData").data
  df = df[['Lottery', 'Literacy', 'Wealth', 'Region']].dropna()
  formule = 'Lottery ~ pow(Literacy,2) + log_plus_1(Wealth)'
  mod = smf.ols(formula=formule, data=df)
  res = mod.fit()
  res.params
  </code></pre>
  
  <p>Now I would need <code>pow(Literacy, 2)</code> and <code>log_plus_1(Wealth)</code>. But since they go into the model, I was hoping to get them out of there too. Instead of transforming the data from the original dataset.</p>
  
  <p>In R I would use <code>res$model</code> to get it.</p>