Ejemplo n.º 1
0
    def setupClass(cls):
        if not _have_x13:
            raise SkipTest('X13/X12 not available')

        import pandas as pd
        from statsmodels.datasets import macrodata, co2
        dta = macrodata.load_pandas().data
        dates = dates_from_range('1959Q1', '2009Q3')
        index = pd.DatetimeIndex(dates)
        dta.index = index
        cls.quarterly_data = dta.dropna()

        dta = co2.load_pandas().data
        dta['co2'] = dta.co2.interpolate()
        cls.monthly_data = dta.resample('M')

        cls.monthly_start_data = dta.resample('MS')
Ejemplo n.º 2
0
    def setupClass(cls):
        if not _have_x13:
            raise SkipTest("X13/X12 not available")

        import pandas as pd
        from statsmodels.datasets import macrodata, co2

        dta = macrodata.load_pandas().data
        dates = dates_from_range("1959Q1", "2009Q3")
        index = pd.DatetimeIndex(dates)
        dta.index = index
        cls.quarterly_data = dta.dropna()

        dta = co2.load_pandas().data
        dta["co2"] = dta.co2.interpolate()
        cls.monthly_data = dta.resample("M")

        cls.monthly_start_data = dta.resample("MS")
Ejemplo n.º 3
0
    def setup_class(cls):
        import pandas as pd
        from statsmodels.datasets import macrodata, co2
        dta = macrodata.load_pandas().data
        index = pd.PeriodIndex(start='1959Q1', end='2009Q3', freq='Q')
        dta.index = index
        cls.quarterly_data = dta.dropna()

        dta = co2.load_pandas().data
        dta['co2'] = dta.co2.interpolate()
        cls.monthly_data = dta.resample('M')
        # change in pandas 0.18 resample is deferred object
        if not isinstance(cls.monthly_data, (pd.DataFrame, pd.Series)):
            cls.monthly_data = cls.monthly_data.mean()

        cls.monthly_start_data = dta.resample('MS')
        if not isinstance(cls.monthly_start_data, (pd.DataFrame, pd.Series)):
            cls.monthly_start_data = cls.monthly_start_data.mean()
Ejemplo n.º 4
0
    def setupClass(cls):
        if not _have_x13:
            raise SkipTest('X13/X12 not available')

        import pandas as pd
        from statsmodels.datasets import macrodata, co2
        dta = macrodata.load_pandas().data
        dates = dates_from_range('1959Q1', '2009Q3')
        index = pd.DatetimeIndex(dates)
        dta.index = index
        cls.quarterly_data = dta.dropna()

        dta = co2.load_pandas().data
        dta['co2'] = dta.co2.interpolate()
        cls.monthly_data = dta.resample('M')
        # change in pandas 0.18 resample is deferred object
        if not isinstance(cls.monthly_data, (pd.DataFrame, pd.Series)):
            cls.monthly_data = cls.monthly_data.mean()

        cls.monthly_start_data = dta.resample('MS')
        if not isinstance(cls.monthly_start_data, (pd.DataFrame, pd.Series)):
            cls.monthly_start_data = cls.monthly_start_data.mean()
Ejemplo n.º 5
0
    def setupClass(cls):
        if not _have_x13:
            raise SkipTest('X13/X12 not available')

        import pandas as pd
        from statsmodels.datasets import macrodata, co2
        dta = macrodata.load_pandas().data
        dates = dates_from_range('1959Q1', '2009Q3')
        index = pd.DatetimeIndex(dates)
        dta.index = index
        cls.quarterly_data = dta.dropna()

        dta = co2.load_pandas().data
        dta['co2'] = dta.co2.interpolate()
        cls.monthly_data = dta.resample('M')
        # change in pandas 0.18 resample is deferred object
        if not isinstance(cls.monthly_data, (pd.DataFrame, pd.Series)):
            cls.monthly_data = cls.monthly_data.mean()

        cls.monthly_start_data = dta.resample('MS')
        if not isinstance(cls.monthly_start_data, (pd.DataFrame, pd.Series)):
            cls.monthly_start_data = cls.monthly_start_data.mean()
import george
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.datasets import co2
from george import kernels

#Load data
data = co2.load_pandas().data
t = 2000 + (np.array(data.index.to_julian_date()) - 2451545.0) / 365.25
y = np.array(data.co2)
m = np.isfinite(t) & np.isfinite(y) & (t < 1996)
t, y = t[m][::4], y[m][::4]

plt.plot(t, y, ".k")
plt.xlim(t.min(), t.max())
plt.xlabel("year")
plt.ylabel("CO$_2$ in ppm")

#Load kernels
k1 = 66**2 * kernels.ExpSquaredKernel(metric=67**2)
k2 = 2.4**2 * kernels.ExpSquaredKernel(90**2) * kernels.ExpSine2Kernel(
    gamma=2 / 1.3**2, log_period=0.0)
k3 = 0.66**2 * kernels.RationalQuadraticKernel(log_alpha=np.log(0.78),
                                               metric=1.2**2)
k4 = 0.18**2 * kernels.ExpSquaredKernel(1.6**2)
kernel = k1 + k2 + k3 + k4

gp = george.GP(kernel,
               mean=np.mean(y),
               fit_mean=True,
               white_noise=np.log(0.19**2),
Ejemplo n.º 7
0
def test_co2_python3():
    # this failed in pd.to_datetime on Python 3 with pandas <= 0.12.0
    dta = co2.load_pandas()
Ejemplo n.º 8
0
def test_co2_python3():
    # this failed in pd.to_datetime on Python 3 with pandas <= 0.12.0
    dta = co2.load_pandas()