Beispiel #1
0
    def setup_class(cls):
        # Test simple exponential smoothing (FPP: 7.1) against fpp::ses, with
        # a fixed coefficient 0.6 and simple initialization
        mod = ExponentialSmoothing(oildata, initialization_method='simple')
        res = mod.filter([results_params['oil_fpp2']['alpha']])

        super().setup_class('oil_fpp2', res)
Beispiel #2
0
    def setup_class(cls):
        oildata_copy = oildata.copy()
        oildata_copy.name = ("oil", "data")
        mod = ExponentialSmoothing(oildata_copy,
                                   initialization_method='simple')
        res = mod.filter([results_params['oil_fpp2']['alpha']])

        super().setup_class('oil_fpp2', res)
    def setup_class(cls):
        # Test simple exponential smoothing (FPP: 7.1) against forecast::ets,
        # with estimated coefficients
        mod = ExponentialSmoothing(oildata,
                                   initialization_method='estimated',
                                   concentrate_scale=False)
        res = mod.filter([
            results_params['oil_ets']['alpha'],
            results_params['oil_ets']['sigma2'],
            results_params['oil_ets']['l0']
        ])

        super().setup_class('oil_ets', res)
    def setup_class(cls):
        # Test Holt-Winters seasonal method (FPP: 7.5) with no trend
        # against forecast::ets, with estimated coefficients

        mod = ExponentialSmoothing(aust, seasonal=4, concentrate_scale=False)
        params = np.r_[results_params['aust_ets3']['alpha'],
                       results_params['aust_ets3']['gamma'],
                       results_params['aust_ets3']['sigma2'],
                       results_params['aust_ets3']['l0'],
                       results_params['aust_ets3']['s0_0'],
                       results_params['aust_ets3']['s0_1'],
                       results_params['aust_ets3']['s0_2']]
        res = mod.filter(params)

        super().setup_class('aust_ets3', res)
def test_concentrated_initialization():
    # Compare a model where initialization is concentrated out versus
    # numarical maximum likelihood estimation
    mod1 = ExponentialSmoothing(oildata, initialization_method='concentrated')
    mod2 = ExponentialSmoothing(oildata)

    # First, fix the other parameters at a particular value
    res1 = mod1.filter([0.1])
    res2 = mod2.fit_constrained({'smoothing_level': 0.1}, disp=0)

    # Alternatively, estimate the remaining parameters
    res1 = mod1.fit(disp=0)
    res2 = mod2.fit(disp=0)

    assert_allclose(res1.llf, res2.llf)
    assert_allclose(res1.initial_state, res2.initial_state, rtol=1e-5)
    def setup_class(cls):
        # Test Holt's linear trend method (FPP: 7.2) with a damped trend
        # against forecast::ets, with estimated coefficients

        mod = ExponentialSmoothing(air,
                                   trend=True,
                                   damped_trend=True,
                                   concentrate_scale=False)
        params = [
            results_params['air_ets']['alpha'],
            results_params['air_ets']['beta'],
            results_params['air_ets']['phi'],
            results_params['air_ets']['sigma2'],
            results_params['air_ets']['l0'], results_params['air_ets']['b0']
        ]
        res = mod.filter(params)

        super().setup_class('air_ets', res)
    def setup_class(cls):
        # Test Holt's linear trend method (FPP: 7.2) against fpp::holt,
        # with fixed coefficients and simple initialization

        mod = ExponentialSmoothing(air,
                                   trend=True,
                                   concentrate_scale=False,
                                   initialization_method='simple')
        # alpha, beta^*
        params = [
            results_params['air_fpp1']['alpha'],
            results_params['air_fpp1']['beta_star'],
            results_params['air_fpp1']['sigma2']
        ]
        # beta = alpha * beta^*
        params[1] = params[0] * params[1]
        res = mod.filter(params)

        super().setup_class('air_fpp1', res)
    def setup_class(cls):
        # Test Holt-Winters seasonal method (FPP: 7.5) against fpp::hw,
        # with estimated coefficients

        mod = ExponentialSmoothing(aust,
                                   trend=True,
                                   seasonal=4,
                                   concentrate_scale=False)
        params = np.r_[results_params['aust_fpp1']['alpha'],
                       results_params['aust_fpp1']['beta'],
                       results_params['aust_fpp1']['gamma'],
                       results_params['aust_fpp1']['sigma2'],
                       results_params['aust_fpp1']['l0'],
                       results_params['aust_fpp1']['b0'],
                       results_params['aust_fpp1']['s0_0'],
                       results_params['aust_fpp1']['s0_1'],
                       results_params['aust_fpp1']['s0_2']]
        res = mod.filter(params)

        super().setup_class('aust_fpp1', res)