title: How do I do an OLS on GLS time series regression in python?
body: <p>I am attempting to transfer my team's Eview code to Python and I got stock with the following line in Eviews:</p>
  <p>equation eq_LSTrend.ls(cov=hac)          log({Price})=c(1) * @trend + c(2).</p>
  <p>Here, the time regression analysis of a certain time window is to be performed on the log(price) and the intercept c(1) as well as the slope c(2) have to be determined.</p>
  <p>Let's say I have the following df:</p>
  <pre class="lang-py prettyprint-override"><code>    import pandas as pd 
      Range = pd.date_range('1990-01-01', periods=8, freq='D')
      log_price = [5.0835, 5.0906, 5.0946, 5.0916, 5.0825, 5.0833, 5.0782, 5.0709]
      df = pd.DataFrame({ 'Date': Range, 'Log Price': log_price })
      df.set_index('Date', inplace=True)
  </code></pre>
  <p>And the df looks like this:</p>
  <pre><code>Date          Log Price       
  1990-01-01     5.0835
  1990-01-02     5.0906
  1990-01-03     5.0946
  1990-01-04     5.0916
  1990-01-05     5.0825
  1990-01-06     5.0833
  1990-01-07     5.0782
  1990-01-08     5.0709
  </code></pre>
  <p>How could I, for example, take a rolling 5 period window, do a OLS or GLS analysis and get the wanted parameters (the slope and the intercept parameters?)</p>
  <p>Also, which library would be appropriate for it (statsmodels or maybe some other library)?</p>
  <p>Ideally, the code would look something like this:</p>
  <pre class="lang-py prettyprint-override"><code>   df_window =  df.rolling(window = 5)
     slope_output = sm.GLS(df_window).slope
  </code></pre>
  <p>or if separate columns have to be provided as an input (in this case I would leave &quot;Date&quot; as a separate column in df)</p>
  <pre class="lang-py prettyprint-override"><code>  df_window =  df.rolling(window = 5)
    slope_output = sm.GLS(depend_var = df_window[&quot;Log Price&quot;], independ_var = df_window[&quot;Date&quot;]).slope
  </code></pre>
  <p>I am quite new to python so please pardon my bad coding!</p>