title: Rolling Regression on python
body: <p>I am trying to run rolling regression for several x_variable using the below code:</p>
  <pre><code># Get data for specified date range
  pred = pred[beg_date:end_date]
  
  # Lag and standardize pred
  pred[var_list_all] = pred[var_list_all].shift(1)
  pred[var_list_all] = preprocessing.StandardScaler().fit_transform(pred[var_list_all])
  
  # Initialize dictionary of lists
  d = {}
  for i in ['coeff', 't-stat', 'r2']:
      d[i] = []
  
  # Run bi-variate regression for each pred variable
  y_var = 'EP'
  for x_var in var_list_all:
      formula = y_var + ' ~ ' + x_var
      results = RollingOLS.from_formula(formula, window=60, data=pred)
  
      d['coeff'].append(results.params[x_var])
      d['t-stat'].append(results.params[x_var] / results.bse[x_var])
      d['r2'].append(results.rsquared * 100)
  </code></pre>
  <p>The aim is to collect the coefficient, t-stat and r2 for each variable and plot the r2 for each on separate graphs.</p>
  <p>Whenever I am running the regression I keep on getting the following message:</p>
  <blockquote>
  <p>AttributeError: 'NoneType' object has no attribute 'f_locals'</p>
  </blockquote>
  <p>I've also tried the example on <a href="https://www.statsmodels.org/stable/examples/notebooks/generated/rolling_ls.html" rel="nofollow noreferrer">https://www.statsmodels.org/stable/examples/notebooks/generated/rolling_ls.html</a> to see if I do understand what is going on, but I get the same error message.</p>
  <p>I am not quite sure what I'm doing wrong.</p>
  <p>Would appreciate any help in solving this issue.</p>
  <p>Thanks in advance.</p>