Skip to content

Commit

Permalink
update to include statsmodels to estimate ar1 process and remove ols …
Browse files Browse the repository at this point in the history
…import from pandas
  • Loading branch information
natashawatkins committed May 12, 2017
1 parent 99e17bb commit fedc715
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions quantecon/estspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from __future__ import division, print_function
import numpy as np
from numpy.fft import fft
from pandas import ols, Series
from pandas import DataFrame
import statsmodels.api as sm


def smooth(x, window_len=7, window='hanning'):
Expand Down Expand Up @@ -140,11 +141,9 @@ def ar_periodogram(x, window='hanning', window_len=7):
"""
# === run regression === #
x_current, x_lagged = x[1:], x[:-1] # x_t and x_{t-1}
x_current, x_lagged = Series(x_current), Series(x_lagged) # pandas series
results = ols(y=x_current, x=x_lagged, intercept=True, nw_lags=1)
e_hat = results.resid.values
phi = results.beta['x']
results = sm.tsa.AR(x).fit(maxlag=1, cov_type='HAC', cov_kwds={'maxlags':1})
e_hat = results.resid
phi = results.params[1]

# === compute periodogram on residuals === #
w, I_w = periodogram(e_hat, window=window, window_len=window_len)
Expand Down

0 comments on commit fedc715

Please # to comment.