from __future__ import print_function
import numpy as np
#import statsmodels.linear_model.regression as smreg

from scipy import special

import statsmodels.api as sm
from statsmodels.datasets.macrodata import data
dta = data.load()
gdp = np.log(dta.data['realgdp'])

from numpy import polynomial
from scipy import special


maxorder = 20
polybase = special.chebyt
polybase = special.legendre

t = np.linspace(-1,1,len(gdp))

exog = np.column_stack([polybase(i)(t) for i in range(maxorder)])

fitted = [sm.OLS(gdp, exog[:, :maxr]).fit().fittedvalues for maxr in
          range(2,maxorder)]

print((np.corrcoef(exog[:,1:6], rowvar=0)*10000).astype(int))

import matplotlib.pyplot as plt
Exemple #2
0
from __future__ import print_function
from .diagnostic import unitroot_adf

import statsmodels.datasets.macrodata.data as macro

macrod = macro.load().data

print(macro.NOTE)

print(macrod.dtype.names)

datatrendli = [('realgdp', 1), ('realcons', 1), ('realinv', 1),
               ('realgovt', 1), ('realdpi', 1), ('cpi', 1), ('m1', 1),
               ('tbilrate', 0), ('unemp', 0), ('pop', 1), ('infl', 0),
               ('realint', 0)]

print('%-10s %5s %-8s' % ('variable', 'trend', '  adf'))
for name, torder in datatrendli:
    adf_, pval = unitroot_adf(macrod[name], trendorder=torder)[:2]
    print('%-10s %5d %8.4f %8.4f' % (name, torder, adf_, pval))
from __future__ import print_function
from .diagnostic import unitroot_adf

import statsmodels.datasets.macrodata.data as macro

macrod = macro.load().data

print(macro.NOTE)

print(macrod.dtype.names)

datatrendli = [
               ('realgdp', 1),
               ('realcons', 1),
               ('realinv', 1),
               ('realgovt', 1),
               ('realdpi', 1),
               ('cpi', 1),
               ('m1', 1),
               ('tbilrate', 0),
               ('unemp',0),
               ('pop', 1),
               ('infl',0),
               ('realint', 0)
               ]

print('%-10s %5s %-8s' % ('variable', 'trend', '  adf'))
for name, torder in datatrendli:
    adf_, pval = unitroot_adf(macrod[name], trendorder=torder)[:2]
    print('%-10s %5d %8.4f %8.4f' % (name, torder, adf_, pval))
Exemple #4
0
from statsmodels.tsa.stattools import adfuller
import statsmodels.datasets.macrodata.data as macro

macrod = macro.load(as_pandas=False).data

print(macro.NOTE)

print(macrod.dtype.names)

datatrendli = [('realgdp', 1), ('realcons', 1), ('realinv', 1),
               ('realgovt', 1), ('realdpi', 1), ('cpi', 1), ('m1', 1),
               ('tbilrate', 0), ('unemp', 0), ('pop', 1), ('infl', 0),
               ('realint', 0)]

print('%-10s %5s %-8s' % ('variable', 'trend', '  adf'))
for name, torder in datatrendli:
    c_order = {0: "nc", 1: "c"}
    adf_, pval = adfuller(macrod[name], regression=c_order[torder])[:2]
    print('%-10s %5d %8.4f %8.4f' % (name, torder, adf_, pval))

from __future__ import print_function
import numpy as np
#import statsmodels.linear_model.regression as smreg

from scipy import special

import statsmodels.api as sm
from statsmodels.datasets.macrodata import data
dta = data.load(as_pandas=False)
gdp = np.log(dta.data['realgdp'])


maxorder = 20
polybase = special.chebyt
polybase = special.legendre

t = np.linspace(-1,1,len(gdp))

exog = np.column_stack([polybase(i)(t) for i in range(maxorder)])

fitted = [sm.OLS(gdp, exog[:, :maxr]).fit().fittedvalues for maxr in
          range(2,maxorder)]

print((np.corrcoef(exog[:,1:6], rowvar=0)*10000).astype(int))

import matplotlib.pyplot as plt

plt.figure()
plt.plot(gdp, 'o')
from __future__ import print_function
import numpy as np
#import statsmodels.linear_model.regression as smreg

from scipy import special

import statsmodels.api as sm
from statsmodels.datasets.macrodata import data
dta = data.load(as_pandas=False)
gdp = np.log(dta.data['realgdp'])

from numpy import polynomial
from scipy import special

maxorder = 20
polybase = special.chebyt
polybase = special.legendre

t = np.linspace(-1, 1, len(gdp))

exog = np.column_stack([polybase(i)(t) for i in range(maxorder)])

fitted = [
    sm.OLS(gdp, exog[:, :maxr]).fit().fittedvalues
    for maxr in range(2, maxorder)
]

print((np.corrcoef(exog[:, 1:6], rowvar=0) * 10000).astype(int))

import matplotlib.pyplot as plt
import numpy as np
#import statsmodels.linear_model.regression as smreg

from scipy import special

import statsmodels.api as sm
from statsmodels.datasets.macrodata import data
dta = data.load()
gdp = np.log(dta.data['realgdp'])

from numpy import polynomial
from scipy import special

maxorder = 20
polybase = special.chebyt
polybase = special.legendre

t = np.linspace(-1, 1, len(gdp))

exog = np.column_stack([polybase(i)(t) for i in range(maxorder)])

fitted = [
    sm.OLS(gdp, exog[:, :maxr]).fit().fittedvalues
    for maxr in range(2, maxorder)
]

print(np.corrcoef(exog[:, 1:6], rowvar=0) * 10000).astype(int)

import matplotlib.pyplot as plt

plt.figure()